Ejemplo n.º 1
0
        public RepoPaths GetRepoPaths(string currentPath, bool noCache)
        {
            if (string.IsNullOrWhiteSpace(currentPath))
            {
                throw new ArgumentException("Current path cannot be empty");
            }

            var       fixedCurPath = DWPSUtils.ForceTrailingSlash(currentPath);
            var       refCurPath   = "REF" + fixedCurPath;
            RepoPaths result       = null;

            if (!noCache)
            {
                result = RepoCache.Get <RepoPaths>(refCurPath);
            }

            if (result == null)
            {
                result = BuildRepoPaths(currentPath);
                RepoCache.Add(refCurPath, result, new TimeSpan(0, 10, 0), true);
            }

            result.IgnoreCache = noCache;

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     添加一个封包片
        /// </summary>
        /// <param name="key">唯一消息Id</param>
        /// <param name="message">封包片</param>
        /// <param name="timeSpan">过期时间</param>
        /// <param name="maxPacketCount">
        ///     最大封包片数
        ///     <para>* 第一次调用时设置此值,以后默认传-1即可。</para>
        /// </param>
        /// <returns>如果返回值不为null, 则证明已经拼接为一个完整的消息</returns>
        public T Add(int key, T message, TimeSpan timeSpan, int maxPacketCount = -1)
        {
            IReadonlyCacheStub <IMultiPacketStub <T> > stub = _caches.Get(key);

            if (stub != null)
            {
                return(stub.Cache.AddPacket(message) ? PickupMessage(stub.Cache) : default(T));
            }
            IMultiPacketStub <T> multiPacketStub = new MultiPacketStub <T>(key, maxPacketCount);

            multiPacketStub.AddPacket(message);
            _caches.Add(key, multiPacketStub, timeSpan);
            return(default(T));
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     添加一个新的缓存
 /// </summary>
 /// <param name="key">缓存Key</param>
 /// <param name="obj">要缓存对的象</param>
 /// <param name="expireTime">过期时间</param>
 /// <returns>返回缓存对象</returns>
 public IReadonlyCacheStub <V> Add(K key, V obj, DateTime expireTime)
 {
     _proxy.Add(key, obj, expireTime);
     return(_innerContainer.Add(key, obj, expireTime));
 }