SharedCacheClientBase
What every client does around a backend call.
Nebula · Packages/com.1by3.nebula/Runtime/SharedCache/SharedCacheClient.cspublic abstract class SharedCacheClientBase : ISharedCacheClientWhat every client does around a backend call. Both calls do their work on the thread pool, so the task completes off the Unity main thread and the call returns before any disk or network work starts. A client lets at most maxConcurrent calls run at once (the rest wait), gives each call Timeout to finish, backs off for a few seconds after a failure so a stopped orchestrator does not make every call wait out its timeout, and writes one log line per call.
Constructors
SharedCacheClientBase
protected SharedCacheClientBase(int maxObjectBytes, int maxConcurrent);Fields
DefaultTimeoutSeconds
public const float DefaultTimeoutSeconds = 30f;Seconds a call may run once it has started.
FailureBackoffSeconds
public const float FailureBackoffSeconds = 5f;Seconds after a failed call during which calls are answered as errors at once.
DefaultMaxConcurrent
public const int DefaultMaxConcurrent = 4;Calls a client runs at the same time, by default.
Properties
MaxObjectBytes
public int MaxObjectBytes { get; }Largest object this client reads or writes, in bytes.
Timeout
public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(DefaultTimeoutSeconds);Longest a call may run once it has started.
Backend
public abstract string Backend { get; }Stats
public SharedCacheStats Stats { get; }Methods
GetCoreAsync
protected abstract Task<byte[]> GetCoreAsync(string key, CancellationToken ct);Read the object. Null for a miss; throw for a failure. Runs on the thread pool, inside the concurrency limit.
PutCoreAsync
protected abstract Task<bool> PutCoreAsync(string key, byte[] bytes, string checksum, CancellationToken ct);Store the object. True when it was written, false when the key was already stored; throw for a failure.
TryGetAsync
public Task<byte[]> TryGetAsync(string key, CancellationToken ct = default);PutAsync
public Task PutAsync(string key, byte[] bytes, CancellationToken ct = default);Dispose
public virtual void Dispose();RemoteSharedCacheClient
ISharedCacheClient for a worker of a mesh or of Nebula Cloud: GET and PUT /cache/{key} on the orchestrator (SharedCacheHost), over the same address and mesh token that RemotePersistenceStore uses.
SharedCacheHost
Serves the orchestrator's ISharedCacheStore to workers (RemoteSharedCacheClient) over the orchestrator's HTTP server, beside PersistenceHost: GET /cache/{key}: the object as application/octet-stream with its SHA-256 in X-Nebula-Checksum;...