-
Notifications
You must be signed in to change notification settings - Fork 9
Home
Jon P Smith edited this page Aug 18, 2022
·
8 revisions
This library provides a .NET distributed cache (referred to as FileStore cache) that works for applications that have multiple instances of the applications running in the same server, e.g. what Azure calls Scale-Out. The shared resource is a json file and for it to work as a distributed cache all the application's instances must be able to access that file.
The FileStore cache has two excellent features:
- It can get cache values blistering fast –
- It only takes ~25 ns. to Get one entry in a cache containing 10,000 entries.
- It has methods called
GetAllKeyValues
\GetAllKeyValues
that return a dictionary with ALL 10,000 entries cache values in ~85 ns.
- It uses a json file as the shared resource which makes it really easy to setup, and you don't need to setup / pay for a database for your cache.
The downsides are:
- It’s slower than database caches when applying updates (i.e,
Set
,Remove
) to the json cache file. For instance, to Set a cache value to an existing 100 cache values takes ~1.5 ms., while a database would normally execute aSet
in around one millisecond. And it gets worse as the cache gets bigger - see the Performance Figures in the README file for the detailed. - It doesn't doesn’t implement the IDistributedCache’s SlidingExpiration feature, because that would make the read performance slow. But it does support the two AbsoluteExpiration versions.
The FileStore cache library has four versions of the code, with the big difference being the type of the value stored in the cache.
Version name | Value type | Description |
---|---|---|
String |
string | Because the cache entries are stored in a json file a value of string is the this version runs everything |
Class |
string + class | This adds the ability to store complex data by serializing a class into a json string. This version also has all the String methods in it |
Bytes |
byte[] | This provides all the features in the String version, but with a value of byte[] |
IDistributedCache |
byte[] | This takes the Bytes version and register it against the IDistributedCache interface |