コード例 #1
0
        public void Set(string key, NancyContext context, DateTime absoluteExpiration)
        {
            SetCache();

            if(_cache == null)
                return;

            _cache[key] = new SerializableResponse(context.Response, absoluteExpiration);

        }
コード例 #2
0
 public CachedResponse(SerializableResponse response)
 {
     ContentType = response.ContentType;
     Headers = response.Headers;
     StatusCode = response.StatusCode;
     OldResponseOutput = response.Contents;
     Contents = GetContents(this.OldResponseOutput);
     Expiration = response.Expiration;
     
     Headers["X-Nancy-LightningCache-Expiration"] = response.Expiration.ToString(CultureInfo.InvariantCulture);
 }
コード例 #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="context"></param>
        /// <param name="absoluteExpiration"></param>
        public void Set(string key, NancyContext context, DateTime absoluteExpiration)
        {
            lock (_lock)
            {
               
                var fileName = Hash(key);
                if (File.Exists(Path.Combine(_cacheDirectory, fileName)))
                    File.Delete(Path.Combine(_cacheDirectory, fileName));
                var serializedResponse = new SerializableResponse(context.Response, absoluteExpiration);
                var json = _javaScriptSerializer.Serialize(serializedResponse);
                File.WriteAllText(Path.Combine(_cacheDirectory, fileName), json);

                DeleteExpiredCacheFiles();
                FileKeyExpirationRecord[fileName] = absoluteExpiration;
            }
        }
コード例 #4
0
 public void Set(string key, NancyContext context, DateTime absoluteExpiration)
 {
     Memory[key] = new SerializableResponse(context.Response, absoluteExpiration);
 }