ServerCacheManager
A class in Root.Township, the global namespace.
Server version of CacheManager: loads or generates cache files in the server's cache folder, and asks clients to confirm they have downloaded a cache.
- Listed in Global namespace: S
- Inherits or implements
CacheManager
Constructors
| Member | What it is |
|---|---|
ServerCacheManager() | Creates a ServerCacheManager with default values. |
Fields
4 private and internal fields
| Member | What it is |
|---|---|
private Dictionary<string, Task> generating | Caches being generated right now, by name. |
private static Logger logger | NLog logger for this class. |
private Dictionary<Connection, Queue<ValueTuple<string, uint>>> requestedFiles | Queue of requested files per connection. Not used in this code. |
private Dictionary<Connection, Dictionary<string, TaskCompletionSource<bool>>> serverChecks | Pending cache download checks per connection and cache name. |
Methods
| Member | What it is |
|---|---|
override async Task CleanCache(string name) | Waits for any generation of the cache to finish, then deletes the file. |
async Task EnsureDownloadedToClient(Connection connection, string cache) | Sends a FileCacheRequest for a cache file to a client and waits for its answer. Throws if the client fails. |
override async Task<T> GetCache<T>(string name, Func<Task<T>> generate, Func<T> createEmpty) | Reads a cache file if it exists; otherwise generates it, writes it to disk and returns it. Waits if it's already generating. |
override void HandleCacheRequest(Connection connection, Stream stream) | Reads a client's reply to a cache request and completes the matching pending check. |
1 private and internal method
| Member | What it is |
|---|---|
private void Disconnected(Connection connection) | When a client disconnects, fails all its pending cache checks. |