Exemplo n.º 1
0
        public void Add(string name, object obj, DateTime expireDate)
        {
            var item = new SimpleFileCacheItem <object>
            {
                Content    = obj,
                ExpireDate = expireDate
            };

            var path = GetCachePath(name);

            SerializeToFile(path, item);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Writes the given object instance to a text file.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="item"></param>
        protected void SerializeToFile(string path, SimpleFileCacheItem <object> item)
        {
            var json = JsonConvert.SerializeObject(item);

            File.WriteAllText(path, json);
        }