Exemplo n.º 1
0
        public static bool CacheObject(KeysetId setId, string key, object obj, TimeSpan validFor)
        {
            bool result;

            if (setId != null)
            {
                if (!CacheSet.AddKey(setId, key))
                {
                    Log.Warning("cacheKeyset for {0} could not be added. (key={1})", setId, key);
                }
            }

            if (validFor == TimeSpan.MinValue)
            {
                result = Program.DataCacheInstance.Instance.Set(key, obj);
            }
            else
            {
                result = Program.DataCacheInstance.Instance.Set(key, obj, validFor);
            }

            if (!result)
            {
                Log.Warning("obj({0}) could not be cached for key:{1}", obj.GetType(), key);
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public static bool CreateKeysetIfNotExists(KeysetId setId)
        {
            if (CacheSet.GetKeysetContext(setId, false) == null)
            {
                CacheSet.GetKeysetContext(setId, true);
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        public static string[] GetKeysFromKeySet(KeysetId setId)
        {
            HashSet <string> set;

            var cksc = CacheSet.GetKeysetContext(setId, false);

            if (cksc == null)
            {
                return(null);
            }

            TryGetCachedResult <HashSet <string> >(cksc.CacheSetKey, out set);

            if (set == null)
            {
                return(null);
            }

            return(set.ToArray());
        }
Exemplo n.º 4
0
 public static bool InvalidateCacheSet(KeysetId setId)
 {
     return(CacheSet.Invalidate(setId));
 }