Example #1
0
        /// <summary>
        /// Overload of Insert operation for bulk inserts. Uses additional EvictionHint and ExpirationHint parameters.
        /// </summary>
        public IDictionary Insert(object[] keys, object[] values, ExpirationHint expiryHint, EvictionHint evictionHint, OperationContext operationContext)
        {

            if (keys == null) throw new ArgumentNullException("keys");
            if (values == null) throw new ArgumentNullException("items");
            if (keys.Length != values.Length)
                throw new ArgumentException("keys count is not equals to values count");

            CacheEntry[] ce = new CacheEntry[values.Length];

            for (int i = 0; i < values.Length; i++)
            {
                object key = keys[i];
                object value = values[i];


                if (key == null) throw new ArgumentNullException("key");
                if (value == null) throw new ArgumentNullException("value");

                if (!key.GetType().IsSerializable)
                    throw new ArgumentException("key is not serializable");
                if (!value.GetType().IsSerializable)
                    throw new ArgumentException("value is not serializable");
                if ((expiryHint != null) && !expiryHint.GetType().IsSerializable)
                    throw new ArgumentException("expiryHint is not not serializable");
                if ((evictionHint != null) && !evictionHint.GetType().IsSerializable)
                    throw new ArgumentException("evictionHint is not serializable");

                // Cache has possibly expired so do default.
                if (!IsRunning) return null; 

                ce[i] = new CacheEntry(value, expiryHint, evictionHint);

            }
            /// update the counters for various statistics
            try
            {
                return Insert(keys, ce, operationContext);
            }
            catch (Exception inner)
            {
                throw;
            }
        }
Example #2
0
        public void Insert(object key, object value, ExpirationHint expiryHint, EvictionHint evictionHint, Hashtable queryInfo, BitSet flag, OperationContext operationContext)
        {
            if (key == null) throw new ArgumentNullException("key");
            if (value == null) throw new ArgumentNullException("value");

            if (!key.GetType().IsSerializable)
                throw new ArgumentException("key is not serializable");
            if (!value.GetType().IsSerializable)
                throw new ArgumentException("value is not serializable");
            if ((expiryHint != null) && !expiryHint.GetType().IsSerializable)
                throw new ArgumentException("expiryHint is not not serializable");
            if ((evictionHint != null) && !evictionHint.GetType().IsSerializable)
                throw new ArgumentException("evictionHint is not serializable");

            // Cache has possibly expired so do default.
            if (!IsRunning)
                return; 

            CacheEntry e = new CacheEntry(value, expiryHint, evictionHint);

            e.QueryInfo = queryInfo;
            e.Flag.Data |= flag.Data;

          

            // update the counters for various statistics
            try
            {
                CacheEntry clone;
                    clone = e;
                _context.PerfStatsColl.MsecPerUpdBeginSample();
                Insert(key, e, null, LockAccessType.IGNORE_LOCK, operationContext);
                _context.PerfStatsColl.MsecPerUpdEndSample();
            }
            catch (Exception inner)
            {
                _context.NCacheLog.CriticalInfo("Cache.Insert():", inner.ToString());
                throw;
            }
        }
Example #3
0
        public void Insert(object key, object value,
                           ExpirationHint expiryHint, EvictionHint evictionHint,
            Hashtable queryInfo, BitSet flag, object lockId, LockAccessType accessType, OperationContext operationContext)
        {
            try
            {
                if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("Cache.Insert", "");
                if (key == null) throw new ArgumentNullException("key");
                if (value == null) throw new ArgumentNullException("value");

                if (!key.GetType().IsSerializable)
                    throw new ArgumentException("key is not serializable");
                if (!value.GetType().IsSerializable)
                    throw new ArgumentException("value is not serializable");
                if ((expiryHint != null) && !expiryHint.GetType().IsSerializable)
                    throw new ArgumentException("expiryHint is not not serializable");
                if ((evictionHint != null) && !evictionHint.GetType().IsSerializable)
                    throw new ArgumentException("evictionHint is not serializable");

                // Cache has possibly expired so do default.
                if (!IsRunning)
                    return; 

                CacheEntry e = new CacheEntry(value, expiryHint, evictionHint);
                e.QueryInfo = queryInfo;
                e.Flag.Data |= flag.Data;

                object dataSize = operationContext.GetValueByField(OperationContextFieldName.ValueDataSize);
                if (dataSize != null)
                    e.DataSize = Convert.ToInt64(dataSize);
          


            /// update the counters for various statistics
            
                _context.PerfStatsColl.MsecPerUpdBeginSample();
                Insert(key, e, lockId, accessType, operationContext);
                _context.PerfStatsColl.MsecPerUpdEndSample();
            }
            catch (Exception inner)
            {
                if (_context.NCacheLog.IsErrorEnabled) _context.NCacheLog.Error("Cache.Insert():", inner.ToString());
                throw;
            }
        }
Example #4
0
        /// <summary>
        /// Overload of Add operation. uses additional paramer of Flag for checking if compressed or not
        /// </summary>
        public void Add(object key, object value,
                        ExpirationHint expiryHint, EvictionHint evictionHint,
                        Hashtable queryInfo, BitSet flag, 
                       OperationContext operationContext)
        {
            if (key == null) throw new ArgumentNullException("key");
            if (value == null) throw new ArgumentNullException("value");

            if (!key.GetType().IsSerializable)
                throw new ArgumentException("key is not serializable");
            if (!value.GetType().IsSerializable)
                throw new ArgumentException("value is not serializable");
            if ((expiryHint != null) && !expiryHint.GetType().IsSerializable)
                throw new ArgumentException("expiryHint is not serializable");
            if ((evictionHint != null) && !evictionHint.GetType().IsSerializable)
                throw new ArgumentException("evictionHint is not serializable");

            // Cache has possibly expired so do default.
            if (!IsRunning) return; 
           
            CacheEntry e = new CacheEntry(value, expiryHint, evictionHint);
            ////Object size for inproc
            object dataSize = operationContext.GetValueByField(OperationContextFieldName.ValueDataSize);
            if (dataSize != null)
                e.DataSize = Convert.ToInt64(dataSize);
           
            e.QueryInfo = queryInfo;
            e.Flag.Data |= flag.Data;        
            try
            {
                HPTimeStats addTime = new HPTimeStats();
                _context.PerfStatsColl.MsecPerAddBeginSample();
                
                addTime.BeginSample();
                Add(key, e, operationContext);
                addTime.EndSample();
                _context.PerfStatsColl.MsecPerAddEndSample();
            }
            catch (Exception inner)
            {
                throw;
            }
        }