Ejemplo n.º 1
0
        /// <summary>
        /// Invalidates the current record from the cache.
        /// </summary>
        /// <param name="record">The record</param>
        public void InvalidateRecord(SysParam record)
        {
            Cache.Remove(record.Name.ToUpper());

            //if (Cache.ContainsKey(record.Name.ToUpper()))
            //	Cache.Remove(record.Name.ToUpper()) ;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Polls all caches on a specific PollNode
        /// </summary>
        /// <param name="nodeType">Type of node to poll</param>
        /// <param name="key">Unique key of the node to poll</param>
        /// <param name="cacheGuid">If included, the specific cache to poll</param>
        /// <returns>Whether the poll was successful</returns>
        public async Task <bool> PollAsync(string nodeType, string key, Guid?cacheGuid = null)
        {
            if (nodeType == Cache.TimedCacheKey)
            {
                MemCache.Remove(key);
                return(true);
            }

            var node = AllPollNodes.FirstOrDefault(p => p.NodeType == nodeType && p.UniqueKey == key);

            if (node == null)
            {
                return(false);
            }

            if (cacheGuid.HasValue)
            {
                var cache = node.DataPollers.FirstOrDefault(p => p.UniqueId == cacheGuid);
                if (cache != null)
                {
                    await cache.PollGenericAsync(true);
                }
                return(cache?.LastPollSuccessful ?? false);
            }
            // Polling an entire server
            await node.PollAsync(true);

            return(true);
        }
Ejemplo n.º 3
0
 public void EvictEntry()
 {
     lock (_keys)
     {
         if (_keys.Any())
         {
             _cache.Remove(_keys[0]);
         }
     }
 }
Ejemplo n.º 4
0
        public void Deleted()
        {
            _cache.Store("key", 123, Encoding.ASCII.GetBytes("Some stuff in here..."), new DateTime(1999, 1, 1));
            _cache.Remove("key");

            var storeNotification = GetNotification();

            Assert.IsInstanceOfType(storeNotification, typeof(StoreNotification));
            var removeNotifaction = GetNotification(1);

            Assert.IsInstanceOfType(removeNotifaction, typeof(RemoveNotification));
        }
Ejemplo n.º 5
0
        public void DoesntTryToEvictRemoved()
        {
            _cache.Add("key1", 0, DateTime.MaxValue, new byte[] { 0, 1, 2, 3, 4 });
            _cache.Add("key2", 0, DateTime.MaxValue, new byte[] { 0, 1, 2, 3, 4 });
            _cache.Remove("key1");
            _cache.Add("key3", 0, DateTime.MaxValue, new byte[] { 0, 1, 2, 3, 4 });
            _cache.Add("key4", 0, DateTime.MaxValue, new byte[] { 0, 1, 2, 3, 4 });

            var keys = _cache.Keys.ToArray();

            Assert.AreEqual(2, keys.Length);
            Assert.IsTrue(keys.Contains("key3"));
            Assert.IsTrue(keys.Contains("key4"));
        }
Ejemplo n.º 6
0
 public void If_I_Try_To_Remove_An_Existent_Item_It_Must_Returns_True()
 {
     string itemInCache = "The quick brown fox jumps over the lazy dog";
     string key = "MS'_favorite_pangram";
     //
     ICache cache = new MemCache();
     cache.Add<string>(itemInCache, key);
     //
     bool result = cache.Remove(key);
     //
     Assert.IsTrue(result);
 }
Ejemplo n.º 7
0
 internal static void RemoveRoles(string ticket) => MemCache.Remove(RolePrefix + ticket);
 /// <summary>
 /// 删除错误计数
 /// </summary>
 public static void DeleteErrorCount()
 {
     MemCache.Remove(CacheKey + "_" + "ErrorCount" + "_" + Ip);
 }
 public static void SetHide(CaptchaDispalyType type)
 {
     MemCache.Remove(GetId(type));
 }
 public void Delete(Guid userId, string smartPlaylistId)
 {
     _decorated.Delete(userId, smartPlaylistId);
     _memCache.Remove(smartPlaylistId);
 }
Ejemplo n.º 11
0
 public void UsedRemoveTest()
 {
     _cache.Store("k", 0, new byte[10], DateTime.MaxValue);
     _cache.Remove("k");
     Assert.AreEqual(0UL, _cache.Used);
 }