public static string ToJson(this oCacheResult rs) { if (rs == null) { return("{}"); } return(JsonConvert.SerializeObject(rs)); }
public string updateReplyCacheKey(UPDATE_TYPE type, oCacheModel cacheModel, string valKey, string jsonObject) { string key = Guid.NewGuid().ToString(); oCacheResult rs = Update(type, cacheModel, valKey, jsonObject); ObjectCache cache = MemoryCache.Default; cache.Set(key, rs, new CacheItemPolicy()); return(key); }
public string getAllJsonReplyCacheKey() { string key = Guid.NewGuid().ToString(); oCacheResult rs = getAllJson(); ObjectCache cache = MemoryCache.Default; cache.Set(key, rs, new CacheItemPolicy()); return(key); }
public static bool clearCacheIfExist(this oCacheResult rs) { if (rs == null || rs.Request == null || string.IsNullOrWhiteSpace(rs.Request.RequestId)) { return(true); } ObjectCache cache = MemoryCache.Default; if (cache.Contains(rs.Request.RequestId)) { cache.Remove(rs.Request.RequestId); } return(false); }
public string searchDynamicReplyCacheKey(oCacheRequest request) { string key = Guid.NewGuid().ToString(); if (string.IsNullOrWhiteSpace(request.RequestId)) { request.RequestId = key; } else { key = request.RequestId; } oCacheResult rs = SearchDynamic(request); ObjectCache cache = MemoryCache.Default; cache.Set(key, rs, new CacheItemPolicy()); return(key); }
public string insertItemReplyCacheKey(string jsonItem) { string key = Guid.NewGuid().ToString(); oCacheResult rs = null; T item = default(T); try { item = JsonConvert.DeserializeObject <T>(jsonItem); rs = insertItem(item); } catch (Exception ex) { rs = new oCacheResult().ToFailConvertJson(ex.Message); } ObjectCache cache = MemoryCache.Default; cache.Set(key, rs, new CacheItemPolicy()); return(key); }