Skip to content

IDistributedCache implementation for Etcd k/v store

License

Notifications You must be signed in to change notification settings

mihaj/EtcdCache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microsoft IDistributedCache implementation for Etcd key value store

  • 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.

1. Build

Clone repository and build DLL. Include DLL in your projects.

How to use

Register with services:

builder.Services.AddEtcdCache(options =>
{
    options.ConnectionString = "http://localhost:2379";
    options.Username = "root";
    options.Password = "root";
});

Inject into class:

public class MyClass
{
    private readonly IDistributedCache _distributedCache;

    public MyClass(IDistributedCache distributedCache)
    {
        _distributedCache = distributedCache;
    }

    public async Task<IActionResult> Write(string key, string value)
    {
        //Save to cache
        await _distributedCache.SetAsync(key,
            Encoding.UTF8.GetBytes(value), new DistributedCacheEntryOptions
            {
                AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(10)
            });

        //Read from cache
        var cachedValue = await _distributedCache.GetAsync(key);
    }

About

IDistributedCache implementation for Etcd k/v store

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages