public async Task <T> GetByKeyAsync <T>(string index, string key) { var db = CacheConnectionProvider.GetDatabase(); var val = await db.HashGetAsync(key, index); return(val.HasValue ? JsonConvert.DeserializeObject <T>(val) : default(T)); }
public async Task UpsertKeyAsync <T>(string key, T entry) where T : new() { var db = CacheConnectionProvider.GetDatabase(); var payload = JsonConvert.SerializeObject(entry, _settings); await db.HashSetAsync(key, new[] { new HashEntry("payload", payload) }); }
public async Task SetKeyExpirationAsync(string key, TimeSpan expiry) { var db = CacheConnectionProvider.GetDatabase(); await db.KeyExpireAsync(key, expiry); }