-
Notifications
You must be signed in to change notification settings - Fork 9
Using Bytes versions
There are two FileStore distributed cache versions that have the value of type byte[]
. They are:
| Version name | Description |
| Bytes
| This provides all the methods in the String
version, but with a value of byte[] |
| IDistributedCache
| This registers Bytes
version against the IDistributedCache
interface, so the extra methods are hidden |
The other difference is the Bytes
and IDistributedCache
versions contain a Refresh
/ RefreshAsync
to match the IDistributedCache
interface, but because the FileStore cache doesn't supports the SlidingExpiration if you call these methods they will throw an NotImplementedException
. Also, if the SlidingExpiration
isn't null in the DistributedCacheEntryOptions
in the Set
/ SetAsync
methods, then will throw an NotImplementedException
too.
These are here for people who are already using distributed caches that implement the IDistributedCache
.
Type | Method names |
---|---|
Read a cache entry | Get(string key) / GetAsync(string key) |
Create/Update a cache entry | Set(string key, byte[] value,...) / SetAsync(string key, byte[] value,...) |
Delete a cache entry | Remove(string key) / RemoveAsync(string key, ...) |
Type | Method names |
---|---|
Get ALL cache entries | GetAllKeyValues / GetAllKeyValuesAsync(...) |
Remove all cache values | ClearAll |
NOTE: Its worth reading this section of the Tips on making your cache fast document to understand that binary data might be bigger that you think.
When you register the FileStore cache the interface that you should use depends on which bytes[] version you select.
Version | interface |
---|---|
Bytes |
IDistributedFileStoreCacheBytes |
IDistributedCache |
IDistributedCache |
As I expect users that want to use either of these versions will already be aware of the IDistributedCache
, and the extra FileStore cache methods have been described in the Using String version documentation.