Exemplo n.º 1
0
        public OpenStreamCommand(string key, StreamModes mode, string group, string subgroup, DateTime absolute,
                                 TimeSpan sliding, CacheDependency dependency, Runtime.CacheItemPriority priority, int methodOverload)
        {
            base.name                     = "OpenStreamCommand";
            _openStreamCommand            = new Alachisoft.NCache.Common.Protobuf.OpenStreamCommand();
            _openStreamCommand.key        = key;
            _openStreamCommand.streamMode = (int)mode;
            _openStreamCommand.group      = group;
            _openStreamCommand.subGroup   = subgroup;
            _methodOverlaod               = methodOverload;

            if (absolute != Alachisoft.NCache.Web.Caching.Cache.NoAbsoluteExpiration)
            {
                _openStreamCommand.absoluteExpiration = absolute.Ticks;
            }

            if (sliding != Alachisoft.NCache.Web.Caching.Cache.NoSlidingExpiration)
            {
                _openStreamCommand.slidingExpiration = sliding.Ticks;
            }

            _openStreamCommand.priority  = (int)priority;
            _openStreamCommand.requestId = base.RequestId;

            if (dependency != null)
            {
                _openStreamCommand.dependency =
                    Alachisoft.NCache.Common.Util.DependencyHelper.GetProtoBufDependency(dependency);
            }
        }
Exemplo 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);
            }
        }