Esempio n. 1
0
        public override IDictionary InsertBulk(string[] keys, CacheItem[] items)
        {
            System.Collections.IDictionary iDict = null;
            string exceptionMessage = null;

            try
            {
                iDict = _webCache.InsertBulk(keys, items);
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem();
                        logItem.Signature         = "InsertBulk(string[] keys, CacheItem[] items)";
                        logItem.NoOfKeys          = keys.Length;
                        logItem.ExceptionMessage  = exceptionMessage;
                        logItem.RuntimeAPILogItem = (RuntimeAPILogItem)_webCache.APILogHashTable[System.Threading.Thread.CurrentThread.ManagedThreadId];
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
                _webCache.APILogHashTable.Remove(System.Threading.Thread.CurrentThread.ManagedThreadId);
            }
            return(iDict);
        }
Esempio n. 2
0
        public override void Insert(string key, object value, DateTime absoluteExpiration, TimeSpan slidingExpiration, Runtime.CacheItemPriority priority)
        {
            string exceptionMessage = null;

            try
            {
                _webCache.Insert(key, value, absoluteExpiration, slidingExpiration, priority);
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem(key, exceptionMessage);
                        logItem.Signature         = "GetCacheItem(string key, ref CacheItemVersion version)";
                        logItem.RuntimeAPILogItem = (RuntimeAPILogItem)_webCache.APILogHashTable[System.Threading.Thread.CurrentThread.ManagedThreadId];
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
                _webCache.APILogHashTable.Remove(System.Threading.Thread.CurrentThread.ManagedThreadId);
            }
        }
Esempio n. 3
0
        public override void Insert(string key, CacheItem item, LockHandle lockHandle, bool releaseLock)
        {
            string exceptionMessage = null;

            try
            {
                _webCache.Insert(key, item, lockHandle, releaseLock);
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem(key, item, exceptionMessage);
                        logItem.Signature         = "Insert(string key, CacheItem item, LockHandle lockHandle, bool releaseLock)";
                        logItem.RuntimeAPILogItem = (RuntimeAPILogItem)_webCache.APILogHashTable[System.Threading.Thread.CurrentThread.ManagedThreadId];
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
                _webCache.APILogHashTable.Remove(System.Threading.Thread.CurrentThread.ManagedThreadId);
            }
        }
Esempio n. 4
0
        public override object Get(string key, TimeSpan lockTimeout, ref LockHandle lockHandle, bool acquireLock)
        {
            Object obj = null;

            try
            {
                obj = _webCache.Get(key, lockTimeout, ref lockHandle, acquireLock);
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem();
                        logItem.Signature         = "Get(string key, TimeSpan lockTimeout, ref LockHandle lockHandle, bool acquireLock)";
                        logItem.Key               = key;
                        logItem.LockTimeout       = lockTimeout;
                        logItem.AcquireLock       = acquireLock;
                        logItem.RuntimeAPILogItem = (RuntimeAPILogItem)_webCache.APILogHashTable[System.Threading.Thread.CurrentThread.ManagedThreadId];
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
                _webCache.APILogHashTable.Remove(System.Threading.Thread.CurrentThread.ManagedThreadId);
            }

            return(obj);
        }
Esempio n. 5
0
        public override CacheItem GetCacheItem(string key, TimeSpan lockTimeout, ref LockHandle lockHandle, bool acquireLock)
        {
            CacheItem cItem            = null;
            string    exceptionMessage = null;

            try
            {
                cItem = _webCache.GetCacheItem(key, lockTimeout, ref lockHandle, acquireLock);
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem(key, exceptionMessage);
                        logItem.Signature         = "GetCacheItem(string key, TimeSpan lockTimeout, ref LockHandle lockHandle, bool acquireLock)";
                        logItem.LockTimeout       = lockTimeout;
                        logItem.AcquireLock       = acquireLock;
                        logItem.RuntimeAPILogItem = (RuntimeAPILogItem)_webCache.APILogHashTable[System.Threading.Thread.CurrentThread.ManagedThreadId];
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
                _webCache.APILogHashTable.Remove(System.Threading.Thread.CurrentThread.ManagedThreadId);
            }
            return(cItem);
        }
Esempio n. 6
0
        public override object Remove(string key)
        {
            object obj = null;
            string exceptionMessage = null;

            try
            {
                obj = _webCache.Remove(key);
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem(key, exceptionMessage);
                        logItem.Signature         = "Remove(string key)";
                        logItem.RuntimeAPILogItem = (RuntimeAPILogItem)_webCache.APILogHashTable[System.Threading.Thread.CurrentThread.ManagedThreadId];
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
            }
            return(obj);
        }
Esempio n. 7
0
        public override void DeleteBulk(string[] keys)
        {
            string exceptionMessage = null;

            try
            {
                _webCache.DeleteBulk(keys);
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem();
                        logItem.Signature        = "DeleteBulk(string[] keys)";
                        logItem.NoOfKeys         = keys.Length;
                        logItem.ExceptionMessage = exceptionMessage;
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
            }
        }
Esempio n. 8
0
        public override void Clear()
        {
            string exceptionMessage = null;

            try
            {
                _webCache.Clear();
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem();
                        logItem.Signature        = "Clear()";
                        logItem.ExceptionMessage = exceptionMessage;
                        _apiLogger.Log(logItem);;
                    }
                }
                catch (Exception)
                { }
            }
        }
Esempio n. 9
0
        public override bool Contains(string key)
        {
            bool   result;
            string exceptionMessage = null;

            try
            {
                result = _webCache.Contains(key);
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem();
                        logItem.Signature        = "Contains(string key)";
                        logItem.Key              = key;
                        logItem.ExceptionMessage = exceptionMessage;
                        _apiLogger.Log(logItem);;
                    }
                }
                catch (Exception)
                { }
            }
            return(result);
        }
Esempio n. 10
0
        public override void RegisterCacheNotification(string key, CacheDataNotificationCallback callback, Runtime.Events.EventType eventType)
        {
            string exceptionMessage = null;

            try
            {
                _webCache.RegisterCacheNotificationInternal(key, callback, eventType, EventDataFilter.None, true);
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem();
                        logItem.Signature        = "RegisterCacheNotification(string key, CacheDataNotificationCallback selectiveCacheDataNotificationCallback, Runtime.Events.EventType eventType)";
                        logItem.ExceptionMessage = exceptionMessage;
                        logItem.Key = key;
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
            }
        }
Esempio n. 11
0
        public override void UnRegisterCacheNotification(string[] keys, CacheDataNotificationCallback callback, Runtime.Events.EventType eventType)
        {
            string exceptionMessage = null;

            try
            {
                _webCache.UnRegisterCacheNotificationInternal(keys, callback, eventType);
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem();
                        logItem.Signature        = "UnRegisterCacheNotification(string[] keys, CacheDataNotificationCallback callback, Runtime.Events.EventType eventType)";
                        logItem.NoOfKeys         = keys.Length;
                        logItem.ExceptionMessage = exceptionMessage;
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
            }
        }
Esempio n. 12
0
        public override int GetHashCode()
        {
            int    result;
            string exceptionMessage = null;

            try
            {
                result = _webCache.GetHashCode();
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem();
                        logItem.Signature        = "GetHashCode()";
                        logItem.ExceptionMessage = exceptionMessage;
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
            }
            return(result);
        }
Esempio n. 13
0
        public override bool Equals(object obj)
        {
            bool   result           = false;
            string exceptionMessage = null;

            try
            {
                result = _webCache.Equals(obj);
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem();
                        logItem.Signature        = "Equals(object obj)";
                        logItem.ExceptionMessage = exceptionMessage;
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
            }
            return(result);
        }
Esempio n. 14
0
        public override System.Collections.IEnumerator GetEnumerator()
        {
            System.Collections.IEnumerator iEnum = null;
            string exceptionMessage = null;

            try
            {
                _webCache.GetEnumerator();
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem();
                        logItem.Signature        = "GetEnumerator()";
                        logItem.ExceptionMessage = exceptionMessage;
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
            }
            return(iEnum);
        }
Esempio n. 15
0
        public override void Unlock(string key, LockHandle lockHandle)
        {
            string exceptionMessage = null;

            try
            {
                _webCache.Unlock(key, lockHandle);
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem(key, exceptionMessage);
                        logItem.Signature = "Unlock(string key, LockHandle lockHandle)";
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
            }
        }
Esempio n. 16
0
        public override void Add(string key, object value)
        {
            string exceptionMessage = null;

            try
            {
                _webCache.Add(key, value);
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem(key, exceptionMessage);
                        logItem.Signature         = "Add(string key, object value)";
                        logItem.RuntimeAPILogItem = (RuntimeAPILogItem)_webCache.APILogHashTable[System.Threading.Thread.CurrentThread.ManagedThreadId];
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
                _webCache.APILogHashTable.Remove(System.Threading.Thread.CurrentThread.ManagedThreadId);
            }
        }
Esempio n. 17
0
        public override bool Lock(string key, TimeSpan lockTimeout, out LockHandle lockHandle)
        {
            bool   result;
            string exceptionMessage = null;

            try
            {
                result = _webCache.Lock(key, lockTimeout, out lockHandle);
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem(key, exceptionMessage);
                        logItem.Signature   = "Lock(string key, TimeSpan lockTimeout, out LockHandle lockHandle)";
                        logItem.LockTimeout = lockTimeout;

                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
            }
            return(result);
        }
Esempio n. 18
0
        /// <summary>
        /// Retrieves the specified item from the Cache object.
        /// </summary>
        /// <param name="key">The identifier for the cache item to retrieve.</param>
        /// <returns>The retrieved cache item, or a null reference (Nothing
        /// in Visual Basic) if the key is not found.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="key"/> contains a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentException"><paramref name="key"/> is not serializable.</exception>
        /// <remarks>
        /// <para><b>Note:</b> If exceptions are enabled through the <see cref="ExceptionsEnabled"/>
        /// setting, this property throws exception incase of failure.</para>
        /// </remarks>
        /// <example>The following example demonstrates how to retrieve the value cached for an ASP.NET text
        /// box server control.
        /// <code>
        /// Cache cache = NCache.InitializeCache("myCache");
        ///	cache.Get("MyTextBox.Value");
        ///
        /// </code>
        /// </example>
        public override object Get(string key)
        {
            object obj = null;

            try
            {
                obj = _webCache.Get(key);
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem();
                        logItem.Signature         = "Get(string key)";
                        logItem.Key               = key;
                        logItem.RuntimeAPILogItem = (RuntimeAPILogItem)_webCache.APILogHashTable[System.Threading.Thread.CurrentThread.ManagedThreadId];
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
                _webCache.APILogHashTable.Remove(System.Threading.Thread.CurrentThread.ManagedThreadId);
            }
            return(obj);
        }
Esempio n. 19
0
        internal override CacheEventDescriptor RegisterCacheNotification(CacheDataNotificationCallback cacheDataNotificationCallback, Runtime.Events.EventType eventType, Runtime.Events.EventDataFilter datafilter)
        {
            CacheEventDescriptor result = null;
            string exceptionMessage     = null;

            try
            {
                result = _webCache.RegisterCacheNotification(cacheDataNotificationCallback, eventType, datafilter);
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem();
                        logItem.Signature        = "RegisterCacheNotification(string key, CacheDataNotificationCallback selectiveCacheDataNotificationCallback, Runtime.Events.EventType eventType, Runtime.Events.EventDataFilter datafilter)";
                        logItem.ExceptionMessage = exceptionMessage;
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
            }
            return(result);
        }
Esempio n. 20
0
        public override System.Collections.IDictionary SearchEntries(string query, System.Collections.IDictionary values)
        {
            System.Collections.IDictionary iDict = null;
            string exceptionMessage = null;

            try
            {
                iDict = _webCache.SearchEntries(query, values);
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem();
                        logItem.Signature   = "SearchEntries(string query, System.Collections.IDictionary values)";
                        logItem.Query       = query;
                        logItem.QueryValues = values;
                        if (iDict != null)
                        {
                            logItem.NoOfObjectsReturned = iDict.Count;
                        }
                        logItem.RuntimeAPILogItem = (RuntimeAPILogItem)_webCache.APILogHashTable[System.Threading.Thread.CurrentThread.ManagedThreadId];
                        logItem.ExceptionMessage  = exceptionMessage;
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
                _webCache.APILogHashTable.Remove(System.Threading.Thread.CurrentThread.ManagedThreadId);
            }
            return(iDict);
        }
Esempio n. 21
0
        public override System.Collections.ICollection Search(string query, System.Collections.IDictionary values)
        {
            System.Collections.ICollection iCol = null;
            string exceptionMessage             = null;

            try
            {
                iCol = _webCache.Search(query, values);
            }
            catch (Exception e)
            {
                exceptionMessage = e.Message;
                throw;
            }
            finally
            {
                try
                {
                    if (_debugConfigurations.IsInLoggingInterval())
                    {
                        APILogItem logItem = new APILogItem();
                        logItem.Signature   = "Search(string query, System.Collections.IDictionary values)";
                        logItem.Query       = query;
                        logItem.QueryValues = values;
                        if (iCol != null)
                        {
                            logItem.NoOfObjectsReturned = iCol.Count;
                        }
                        logItem.ExceptionMessage = exceptionMessage;
                        _apiLogger.Log(logItem);
                    }
                }
                catch (Exception)
                { }
            }
            return(iCol);
        }