public virtual void Test() { Console.WriteLine("ISF: {0}", isf.GetDirectoryNames("*")); Console.WriteLine("Test {0}:", this.GetType().Name); Console.WriteLine("cache->{0}", cache); cache[1] = ClassBuilder.BuildResult(1); Thread.Sleep(2000); cache[2] = ClassBuilder.BuildResult(2); cache[3] = ClassBuilder.BuildResult(3); cache[0x300000000] = ClassBuilder.BuildResult(30); cache[0x300000000] = ClassBuilder.BuildResult(33); cache[4] = ClassBuilder.BuildResult(4); Console.WriteLine("cache->{0}", cache); Console.WriteLine("cache[1]->{0}", cache[1]); Console.WriteLine("cache->{0}", cache); cache.Remove(1); Console.WriteLine("cache->{0}", cache); Console.WriteLine("cache[1]->{0}", cache[1]); Console.WriteLine("cache->{0}", cache); Console.WriteLine("cache[2]->{0}", cache[2]); Console.WriteLine("cache->{0}", cache); Console.Write("Serializing state..."); System.IO.FileStream fs = new FileStream("cache_" + this.GetType().Name + ".txt", FileMode.Create); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(fs, cache.State); fs.Close(); Console.WriteLine("Done."); Console.Write("Deserializing state..."); fs = new FileStream("cache_" + this.GetType().Name + ".txt", FileMode.Open); bf = new BinaryFormatter(); cache.State = bf.Deserialize(fs); fs.Close(); Console.WriteLine("Done."); Console.WriteLine("cache->{0}", cache); Console.WriteLine("---"); Console.WriteLine(); }
public virtual CacheManager <int, ResultClass> .CacheItem Calculate(int key) { return(new CacheExpireItem(ClassBuilder.BuildResult(0), DateTime.UtcNow.AddSeconds(1))); //key }
public virtual CacheManager <int, ResultClass> .CacheItem Calculate(int key) { return(new CacheManager <int, ResultClass> .MemoryCacheItem(ClassBuilder.BuildResult(0))); //key }
public virtual CacheManager <long, ResultClass> .CacheItem Calculate(long key) { return(new CacheIsolatedStorageItem(ClassBuilder.BuildResult(0), isf, key, DateTime.UtcNow.AddSeconds(1))); //key }