- IDistributedCache implementation for Etcd k/v store.
- It's a preview version, any feedback welcome.
- I still need to make a nuget out of it.
Clone repository and build DLL. Include DLL in your projects.
Register with services:
builder.Services.AddEtcdCache(options =>{options.ConnectionString="http://localhost:2379";options.Username="root";options.Password="root";});Inject into class:
publicclassMyClass{privatereadonlyIDistributedCache_distributedCache;publicMyClass(IDistributedCachedistributedCache){_distributedCache=distributedCache;}publicasyncTask<IActionResult>Write(stringkey,stringvalue){//Save to cacheawait_distributedCache.SetAsync(key,Encoding.UTF8.GetBytes(value),newDistributedCacheEntryOptions{AbsoluteExpirationRelativeToNow=TimeSpan.FromMinutes(10)});//Read from cachevarcachedValue=await_distributedCache.GetAsync(key);}