Example #1
0
        protected override void ResetObject(object obj)
        {
            CompactCacheEntry entry = obj as CompactCacheEntry;

            if (entry != null)
            {
                entry.Reset();
            }
        }
Example #2
0
        /// <summary>
        /// Create a CompactEntry object
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="absoluteExpiration"></param>
        /// <param name="slidingExpiration"></param>
        /// <param name="priority"></param>
        /// <param name="onRemoveCallback"></param>
        /// <returns></returns>
        private object MakeCompactEntry(string key, object value, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, short onRemoveCallback, short onUpdateCallback, Hashtable queryInfo, BitSet Flag, object lockId, LockAccessType accessType, EventDataFilter updateCallbackFilter, EventDataFilter removeCallabackFilter)
        {
            //we create a user binary object.
            if (this.SerializationEnabled)
            {
                value = UserBinaryObject.CreateUserBinaryObject((byte[])value); 
            }

            if ((short)onRemoveCallback != -1 || (short)onUpdateCallback != -1 )
                value = new CallbackEntry(ClientID, -1, value, onRemoveCallback, onUpdateCallback, Flag, updateCallbackFilter, removeCallabackFilter);
            ////muds:
            ////we can not specify both tags and groups for the same cache item.
            //WebCacheHelper.EvaluateTagsParameters(queryInfo, group);

            byte expType = WebCacheHelper.EvaluateExpirationParameters(absoluteExpiration, slidingExpiration);
            int options = 0;

            if (expType < 2)
            {
                options = expType;
            }

            int prio = Convert.ToInt32(priority);
            prio += 2;
            prio = (prio << 2);
            options = options | prio;

            long expiration = expType == 1 ? absoluteExpiration.Ticks : slidingExpiration.Ticks;

            ExpirationHint hint =  null;

            object entry = new CompactCacheEntry(key, value, hint, 
                                                 expiration, (byte)options, null, queryInfo, Flag, lockId, accessType);
            return entry;
        }
Example #3
0
        /// <summary>
        /// Convert CompactCacheEntry to CacheEntry, CompactCacheEntry may be serialized
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        CacheEntry MakeCacheEntry(CompactCacheEntry cce)
        {
            bool isAbsolute = false;
            int priority = (int)CacheItemPriority.Normal;

            int opt = (int)cce.Options;

            if (opt != 255)
            {
                isAbsolute = Convert.ToBoolean(opt & 1);
                opt = (opt >> 1);
                opt = (opt >> 1);
                priority = opt - 2;
            }

            ExpirationHint eh = ExpirationHelper.MakeExpirationHint(cce.Expiration, isAbsolute);
            CacheEntry e = new CacheEntry(cce.Value, eh, new PriorityEvictionHint((CacheItemPriority)priority));       
            e.QueryInfo = cce.QueryInfo;
            e.Flag = cce.Flag;


            e.LockId = cce.LockId;
            e.LockAccessType = cce.LockAccessType;

            return e;
        }