Skip to main content

ClientCacheManager

A class in Root.Township, Alta.Static.

Client side CacheManager: reads cache files from the local cache folder and downloads missing ones over HTTP from the joined server's web server (port 1761 by default).

Constructors​

MemberWhat it is
ClientCacheManager()Creates a ClientCacheManager with default values.

Fields​

2 private and internal fields
MemberWhat it is
private Dictionary<string, ClientCacheManager.FileDownloader> downloadersDownloads in progress, by file name.
private static Logger loggerLogger for this class.

Methods​

MemberWhat it is
static async void Clean(long limit = 200000000)Deletes the oldest accessed cache files until the cache folder is under the limit (200 MB by default). Runs once when the class loads.
override Task CleanCache(string name)Deletes one named cache file if it exists.
override async Task<T> GetCache<T>(string name, Func<Task<T>> generate, Func<T> createEmpty)Loads a named cache from disk, downloading it first if needed. Returns null if the download fails or no createEmpty is given.
override async void HandleCacheRequest(Connection connection, Stream stream)Handles the server asking the client to have a cache ready: downloads it if missing, then replies whether it succeeded.
2 private and internal methods
MemberWhat it is
private Task<IAltaFile> DownloadCache(string name)Starts a download of a named cache file, or returns the one already running. Tries three times, waiting longer each time.
private void DownloaderFinished(ClientCacheManager.FileDownloader assembly, IAltaFile file)Forgets a finished downloader.