Using system.threading; using system.collections;
namespace MyCache {///
Private static void autoredata () {while (turn (turn) {// Clear timeout No visual discussion version of the memory IF (((data) Hash [obj]) .time Public Static Object Get (String Key) {IF (Hash [Key] == Null) Return Null; Else Return ((DATA) HASH [Key]). base;} // More than a few minutes does not access: When each visit, change the expiration time (unciprocated code) Public Static Void Set (Object Basedata, String Key, Int Cachetime) {set (Basedata, Key, DateTime.now.Addminutes (Cachetime), NULL); Public Static Void Set (Object Basedata, String Key, Int Cachetime, String Callback {set (Basedata, Key, DateTime.now.addminutes (Cachetime), Callback; Public Static Void Set (Object Basedata, String Key, DateTime Removetime) {set (Basedata, Key, Removetime, Null) Public Static Void Set (Object Basedata, String Key, DateTime Removetime, String Callback {if (Hash [Key]! = NULL) Remove (key); Data D = New Data (Basedata, Removetime, Callback); Hash.Add ( Key, d); Private static void remove (String Key) {if (Hash [key] == null) Return; Data D = (DATA) HASH [key]; if (d.callback! = null & d.callback! = "" & D .Base.gettype (). GetMethod (d.callback)! = Null) {try {d.base.gettype (). InvokeMember (D.callback, System.Reflection.BindingFlags.InvokeMethod, Null, D.Base, NULL) Catch {}} Hash.Remove (key);} private datetime Time; public object base; public string callback = ""; public bool islast = false; Public Data (Object Data, DateTime Removetime, String Callback) {this.base = data; this.time = removetime; this.callback = Callback;}}}}