示例#1
0
        public static T Get(string refID)
        {
            ICacheFactory cf                = new CF();
            ICache        cache             = cf.GetCacheManager();
            string        keyName           = MakeKeyName(refID);
            CacheValueRefID <V, T, CF> item = cache.Get <CacheValueRefID <V, T, CF> >(keyName);

            if (item != null)
            {
                item.Remove();
                item = null;
            }

            if (item == null)
            {
                item       = new T();
                item.RefID = refID;
                item.SetValue(item.GetFromSource());
                if (!item.IsDefaultData())
                {
                    cache.Add(keyName, item);
                }
            }
            return((T)item);
        }
示例#2
0
        public static T GetCached(string refID)
        {
            ICacheFactory cf                = new CF();
            ICache        cache             = cf.GetCacheManager();
            string        keyName           = MakeKeyName(refID);
            CacheValueRefID <V, T, CF> item = cache.Get <CacheValueRefID <V, T, CF> >(keyName);

            if (item != null)
            {
                item.Remove();
                item = null;
            }
            return((T)item);
        }