public string SaveToCache([FromBody] CacheSaveModel model)
 {
     try
     {
         CacheHelper cache = new CacheHelper();
         string      json  = cache.SaveToCache(model);
         return(json);
     }
     catch (Exception ex)
     {
         return("ERROR");
     }
 }
Exemple #2
0
        public string SaveToCache(CacheSaveModel model)
        {
            string   cachekey = model.Context + model.Key;
            TimeSpan tvalue   = new TimeSpan(1, 0, 0, 0, 0);

            if (model.ExpiryInSeconds != 0)
            {
                tvalue = new TimeSpan(0, 0, 0, model.ExpiryInSeconds, 0);
            }

            try
            {
                var cache = RedisConnectorHelper.Connection.GetDatabase();
                cache.StringSet(cachekey, model.Data, tvalue);
                cache.KeyExpire(cachekey, tvalue);
                return("OK");
            }
            catch (Exception ex)
            {
                return("ERROR");
            }
        }