Skip to main content

CacheManager

An abstract class in Root.Township, Alta.Static.

Stores generated data (such as forest nodes) as cache files. Instance is a ServerCacheManager on the server and a ClientCacheManager on clients.

Constructors​

MemberWhat it is
protected CacheManager()Creates a CacheManager with default values.

Properties​

MemberWhat it is
static CacheManager Instance { get; set; }The current cache manager. Set by ServerHandler or when joining a server.

Methods​

MemberWhat it is
abstract Task CleanCache(string name)Deletes a cache by name.
Task<T> GetCache<T>(string name, Func<Task<T>> generate)Returns a cache by name, generating it with the given function if it is missing.
abstract Task<T> GetCache<T>(string name, Func<Task<T>> generate, Func<T> createEmpty)Returns a cache by name, generating it with the given function if it is missing.
static string GetCacheName(string context, LocationChunk chunk, int seed)Builds a cache file name from the server ID, chunk, context and seed.
abstract void HandleCacheRequest(Connection connection, Stream stream)Handles a cache request message from a connection.