Esempio n. 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);
        }