public void OnCacheDataNotification(string key, CacheEventArg arg)
 {
     if (_callback != null)
     {
         _callback(key);
     }
 }
Example #2
0
 private void OnItemUpdate(string key, CacheEventArg args)
 {
     if (key.StartsWith(Constants.CREATE_REGION_KEY))
     {
         var region = key.Replace(Constants.CREATE_REGION_KEY, "");
         if (Type == CallbackType.CacheLevelCallback || (Type == CallbackType.RegionSpecificCallback && Region == region))
         {
             if (Callback != null && (Operation & DataCacheOperations.ClearRegion) == DataCacheOperations.ClearRegion)
             {
                 Callback(CacheId, region, "", null, DataCacheOperations.ClearRegion, NotificationDescriptor);
             }
         }
     }
     else
     {
         var keyRegion = DataFormatter.SplitKeyAndRegion(key);
         if (Validate(Type, keyRegion, Key, Region, Callback))
         {
             if ((Operation & DataCacheOperations.ReplaceItem) == DataCacheOperations.ReplaceItem)
             {
                 var cacheItemVersion = args.Item.CacheItemVersion;
                 var version          = new DataCacheItemVersion(cacheItemVersion);
                 Callback(CacheId, keyRegion[1], keyRegion[0], version, DataCacheOperations.ReplaceItem, NotificationDescriptor);
             }
         }
     }
 }
 public void OnCacheDataNotification(string key, CacheEventArg arg)
 {
     if (_callback != null)
     {
         _callback(key, arg.Item.Value, arg.CacheItemRemovedReason);
     }
 }
Example #4
0
 /// <summary>
 /// Raises SyncItemRemoved event when item is removed.
 /// </summary>
 /// <param name="key">key of the item removed.</param>
 /// <param name="value">value of the item removed.</param>
 /// <param name="reason">reason for the item removed.</param>
 public void OnItemRemovedCallback(string key, CacheEventArg eventArg)
 {
     if (_synEventListeners != null)
     {
         foreach (ISyncCacheEventsListener eventListener in _synEventListeners)
         {
             eventListener.SyncItemRemoved(key);
         }
     }
 }
Example #5
0
 internal void OnCacheDataModification(string key, CacheEventArg args)
 {
     if (args.EventType == EventType.ItemAdded)
     {
         OnItemAdded(key, args);
     }
     else if (args.EventType == EventType.ItemUpdated)
     {
         OnItemUpdate(key, args);
     }
     else
     {
         OnItemRemove(key, args);
     }
 }
Example #6
0
        /// <summary>
        /// This method will be used as a callback for cache data notification.
        /// </summary>
        /// <param name="key"> key against which callback was fired. </param>
        /// <param name="cacheEventArgs"> Event arguments. </param>
        private static void KeyNotificationMethod(string key, CacheEventArg cacheEventArgs)
        {
            switch (cacheEventArgs.EventType)
            {
            case EventType.ItemAdded:
                Console.WriteLine("Key: " + key + " is added to the cache");
                break;

            case EventType.ItemRemoved:
                Console.WriteLine("Key: " + key + " is removed from the cache");
                break;

            case EventType.ItemUpdated:
                Console.WriteLine("Key: " + key + " is updated in the cache");
                break;
            }
        }
        private void OnItemRemove(string key, CacheEventArg args)
        {
            DataCacheOperationDescriptor descriptor;

            if (key.StartsWith($"{Constants.CREATE_REGION_KEY}"))
            {
                var region = key.Replace($"{Constants.CREATE_REGION_KEY}", "");
                descriptor = new DataCacheOperationDescriptor(CacheId, region, "", DataCacheOperations.RemoveRegion, null);
            }
            else
            {
                var keyRegion        = DataFormatter.SplitKeyAndRegion(key);
                var cacheItemVersion = args.Item.CacheItemVersion;
                var version          = new DataCacheItemVersion(cacheItemVersion);
                descriptor = new DataCacheOperationDescriptor(CacheId, keyRegion[1], keyRegion[0], DataCacheOperations.RemoveItem, version);
            }

            BulkCallback(CacheId, new DataCacheOperationDescriptor[] { descriptor }, NotificationDescriptor);
        }
Example #8
0
 /// <summary>
 /// Raises SyncItemUpdated event when item is updated in the cache.
 /// </summary>
 /// <param name="key">updated key</param>
 public void OnItemChangedCallback(string key, CacheEventArg eventArg)
 {
     if (_synEventListeners != null)
     {
         if (eventArg.EventType == EventType.ItemUpdated)
         {
             foreach (ISyncCacheEventsListener eventListener in _synEventListeners)
             {
                 eventListener.SyncItemUpdated(key);
             }
         }
         else if (eventArg.EventType == EventType.ItemRemoved)
         {
             foreach (ISyncCacheEventsListener eventListener in _synEventListeners)
             {
                 eventListener.SyncItemRemoved(key);
             }
         }
     }
 }
Example #9
0
 /// <summary>
 /// This method will be used as a callback for cache data notification.
 /// </summary>
 /// <param name="key"> key against which callback was fired. </param>
 /// <param name="cacheEventArgs"> Event arguments. </param>
 public static void CacheDataModified(string key, CacheEventArg cacheEventArgs)
 {
     Console.WriteLine("Cache data modification notification for the the item of the key : {0}", key); //To change body of generated methods, choose Tools | Templates.
 }
 public override void cacheDataModified(string @string, CacheEventArg cea)
 {
     throw new System.NotSupportedException("Not supported yet.");             //To change body of generated methods, choose Tools | Templates.
 }