コード例 #1
0
        public static void Put(IEnumerable key, object value)
        {
            if (GlobalSettings.Pages.Cache().CacheMode == CacheMode.DontUse)
            {
                return;
            }
            UICacheItem item = new UICacheItem();

            item.Key                 = CountKey(key);
            item.Value               = value;
            item.LastUpdatedAt       = DateTime.UtcNow;
            item.LastUsedAt          = DateTime.UtcNow;
            Instance.Items[item.Key] = item;
        }
コード例 #2
0
        public static T Get <T>(IEnumerable key) where T : class
        {
            if (GlobalSettings.Pages.Cache().CacheMode == CacheMode.DontUse)
            {
                return(null);
            }
            string sk = CountKey(key);

            if (Instance.Items.ContainsKey(sk))
            {
                UICacheItem item = Instance.Items[sk];
                if (item.Value is T)
                {
                    item.LastUsedAt = DateTime.UtcNow;
                    return((T)item.Value);
                }
            }
            return(null);
        }