Example #1
0
        public IEntryProcessorResult ProcessEntry(string key, IEntryProcessor entryProcessor, Object[] arguments, BitSet writeOptionFlag, String defaultWriteThru, OperationContext operationContext)
        {
            IEntryProcessorResult result  = null;
            EPCacheEntry          epEntry = null;

            try {
                epEntry = GetEPCacheEntry(key, entryProcessor.IgnoreLock(), operationContext);
                object value = null;
                if (epEntry != null && epEntry.CacheEntry != null)
                {
                    value = epEntry.CacheEntry.Value;
                }
                NCacheMutableEntry mutableEntry = new NCacheMutableEntry(key, value);

                result = new EntryProcessorResult(key, entryProcessor.ProcessEntry(mutableEntry, arguments));

                if (mutableEntry.IsUpdated)
                {
                    epEntry.CacheEntry = MakeCacheEntry(epEntry.CacheEntry, mutableEntry.Value);

                    UpdateEPCacheEntry(key, epEntry, writeOptionFlag, defaultWriteThru);
                }
                else if (mutableEntry.IsRemoved)
                {
                    RemoveEPCacheEntry(key, epEntry, writeOptionFlag, defaultWriteThru);
                }
            } catch (EntryProcessorException ex) {
                return(new EntryProcessorResult(key, ex));
            } catch (Exception ex) {
                return(new EntryProcessorResult(key, new EntryProcessorException(ex)));
            }
            finally
            {
                if (epEntry != null && epEntry.LockHandle != null)
                {
                    try {
                        _cacheRoot.Unlock(key, epEntry.LockHandle.LockId, false, new OperationContext());
                    } catch (Exception ex)
                    {
                        _context.NCacheLog.Error("EntryProcessorManager.ProcesssEntry", "exception is thrown while unlocking key: " + key.ToString() + ex.Message);
                    }
                }
            }
            return(result);
        }
Example #2
0
        private void RemoveEPCacheEntry(string key, EPCacheEntry epCacheEntry, BitSet flag, String writethruProvider)
        {
            CacheEntry     entry      = epCacheEntry.CacheEntry;
            object         lockID     = null;
            LockAccessType lockAccess = LockAccessType.IGNORE_LOCK;

            if (epCacheEntry.LockHandle != null)
            {
                lockAccess = LockAccessType.DEFAULT;
                lockID     = epCacheEntry.LockHandle.LockId;
            }

            OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);

            operationContext.Add(OperationContextFieldName.RaiseCQNotification, true);

            _cacheRoot.Remove(key, flag, null, lockID, 0, lockAccess, writethruProvider, operationContext);
        }
Example #3
0
        private void UpdateEPCacheEntry(Object key, EPCacheEntry epCacheEntry, BitSet writeOptionFlag, String writethruProvider)
        {
            CacheEntry       entry            = epCacheEntry.CacheEntry;
            OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);

            operationContext.Add(OperationContextFieldName.RaiseCQNotification, true);
            object value;

            if (entry.Value is CallbackEntry)
            {
                value = ((CallbackEntry)entry.Value).Value;
            }
            else
            {
                value = entry.Value;
            }
            object obj = _context.CachingSubSystemDataService.GetClientData(value, ref writeOptionFlag, Common.Util.LanguageContext.DOTNET);

            _cacheRoot.Insert(key, obj, entry.ExpirationHint, entry.SyncDependency, entry.EvictionHint, entry.GroupInfo != null ? entry.GroupInfo.Group : null, entry.GroupInfo != null ? entry.GroupInfo.SubGroup : null, entry.QueryInfo, writeOptionFlag, entry.LockId != null ? entry.LockId : null, entry.Version, entry.LockAccessType, writethruProvider, entry.ResyncProviderName != null ? entry.ResyncProviderName : null, operationContext);
        }