示例#1
0
        public async Task <Optional <T> > Get <T>(string key)
        {
            var cachedValue = await _database.StringGetAsync(key).ConfigureAwait(false);

            if (cachedValue.HasValue)
            {
                return(_serializer.Deserialize <T>(cachedValue));
            }
            return(Optional <T> .None());
        }
示例#2
0
 public async Task Subscribe <T>(string channel, Action <T> handler)
 {
     await _subscriber.SubscribeAsync(channel, (_, value) =>
     {
         var message = _serializer.Deserialize <T>(value);
         handler(message);
     }).ConfigureAwait(false);
 }