void _objectCache_ItemRemoved(object sender, LruCacheEventArgs args)
        {
            SoodaCacheEntry e = (SoodaCacheEntry)args.Value;

            logger.Trace("Item removed: {0}. Invalidating dependent collections...", e);
            IList l = e.GetDependentCollections();

            if (l != null)
            {
                foreach (SoodaCachedCollection ck in e.GetDependentCollections())
                {
                    InvalidateCollection(ck);
                }
            }
        }
 public void Add(string className, object primaryKeyValue, SoodaCacheEntry entry, TimeSpan expirationTimeout, bool slidingExpiration)
 {
     _rwlock.AcquireWriterLock(-1);
     try
     {
         SoodaCacheKey cacheKey = new SoodaCacheKey(className, primaryKeyValue);
         _objectCache.Set(cacheKey, entry, expirationTimeout, slidingExpiration);
         if (logger.IsTraceEnabled)
         {
             logger.Trace("Adding {0} to cache.", cacheKey);
         }
     }
     finally
     {
         _rwlock.ReleaseWriterLock();
     }
 }
        public void StoreCollection(string cacheKey, string rootClassName, IList primaryKeys, string[] dependentClassNames, bool evictWhenItemRemoved, TimeSpan expirationTimeout, bool slidingExpiration)
        {
            if (cacheKey != null)
            {
                _rwlock.AcquireWriterLock(-1);
                try
                {
                    if (logger.IsTraceEnabled)
                    {
                        logger.Trace("Storing collection: {0} {1} items. Dependent on: [ {2} ]", cacheKey, primaryKeys.Count, String.Join(",", dependentClassNames));
                    }

                    SoodaCachedCollection cc = new SoodaCachedCollection(cacheKey, rootClassName, primaryKeys);

                    if (evictWhenItemRemoved)
                    {
                        foreach (object o in primaryKeys)
                        {
                            SoodaCacheKey   k = new SoodaCacheKey(rootClassName, o);
                            SoodaCacheEntry e = (SoodaCacheEntry)_objectCache[k];
                            if (e != null)
                            {
                                //logger.Trace("Registering {0} as dependent of {1}", cacheKey, e);
                                e.RegisterDependentCollection(cc);
                            }
                            ;
                        }
                    }
                    _collectionCache.Set(cacheKey, cc, expirationTimeout, slidingExpiration);

                    RegisterDependentCollectionClass(cacheKey, rootClassName, expirationTimeout, slidingExpiration);
                    if (dependentClassNames != null)
                    {
                        for (int i = 0; i < dependentClassNames.Length; ++i)
                        {
                            RegisterDependentCollectionClass(cacheKey, dependentClassNames[i], expirationTimeout, slidingExpiration);
                        }
                    }
                }
                finally
                {
                    _rwlock.ReleaseWriterLock();
                }
            }
        }
示例#4
0
 void ISoodaCache.Add(string className, object primaryKeyValue, SoodaCacheEntry entry, TimeSpan expirationTimeout, bool slidingExpiration)
 {
 }
 public void Add(string className, object primaryKeyValue, SoodaCacheEntry entry, TimeSpan expirationTimeout, bool slidingExpiration)
 {
     _rwlock.AcquireWriterLock(-1);
     try
     {
         SoodaCacheKey cacheKey = new SoodaCacheKey(className, primaryKeyValue);
         _objectCache.Set(cacheKey, entry, expirationTimeout, slidingExpiration);
         if (logger.IsTraceEnabled)
         {
             logger.Trace("Adding {0} to cache.", cacheKey);
         }
     }
     finally
     {
         _rwlock.ReleaseWriterLock();
     }
 }
示例#6
0
 void ISoodaCache.Add(string className, object primaryKeyValue, SoodaCacheEntry entry, TimeSpan expirationTimeout, bool slidingExpiration)
 {
 }