Esempio n. 1
0
        public override void Set(string key, object entry, DateTime utcExpiry)
        {
            string filePath   = GetFilePathFromKey(key);
            var    cachedItem = new CachedItem()
            {
                Item = entry, UtcExpiry = utcExpiry
            };

            SaveCachedItem(cachedItem, filePath);
        }
Esempio n. 2
0
        private void SaveCachedItem(CachedItem cachedItem, string filePath)
        {
            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            using (var stream = File.OpenWrite(filePath))
            {
                var binaryFormatter = new BinaryFormatter();
                binaryFormatter.Serialize(stream, cachedItem);
            }
        }