Beispiel #1
0
        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));
        }
Beispiel #2
0
 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) });
 }
Beispiel #3
0
 public async Task SetKeyExpirationAsync(string key, TimeSpan expiry)
 {
     var db = CacheConnectionProvider.GetDatabase();
     await db.KeyExpireAsync(key, expiry);
 }