Ejemplo n.º 1
0
        /// <summary>
        /// Checks if a packet should be cached, if so it will cache on a key
        /// </summary>
        /// <param name="key">The key to cache on</param>
        /// <param name="request">The request being made to the server</param>
        /// <returns>A new cache object if the request was cachable, false otherwise.</returns>
        protected IPacketCache CacheIfApplicable(String key, Packet request) {
            IPacketCache cache = null;

            var config = this.Configurations.FirstOrDefault(c => c.Matching.IsMatch(key));

            if (config != null) {
                cache = new PacketCache() {
                    Request = request,
                    Expiry = DateTime.Now.Add(config.Ttl)
                };

                this.Cache.Add(key, cache);
            }

            return cache;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Checks if a packet should be cached, if so it will cache on a key
        /// </summary>
        /// <param name="key">The key to cache on</param>
        /// <param name="request">The request being made to the server</param>
        /// <returns>A new cache object if the request was cachable, false otherwise.</returns>
        protected IPacketCache CacheIfApplicable(String key, Packet request)
        {
            IPacketCache cache = null;

            var config = this.Configurations.FirstOrDefault(c => c.Matching.IsMatch(key));

            if (config != null)
            {
                cache = new PacketCache()
                {
                    Request = request,
                    Expiry  = DateTime.Now.Add(config.Ttl)
                };

                this.Cache.Add(key, cache);
            }

            return(cache);
        }