static public void Insert <T>(string key, T value, string filelocation) { Interlocked.Increment(ref Cache.counter); SimpleObject simpleObject = new SimpleObject { Key = key, Value = value, FileLocation = filelocation }; sendQueue.Add(simpleObject); var data = sendQueue.Take(); //this blocks if there are no items in the queue. //Add to cache lock (Cache.LockObject) { Cache.CacheDic[filelocation + key] = simpleObject; } ThreadPool.QueueUserWorkItem(state => { lock (Cache.LockObject) { Storage.WritetoStorage(data.Key, Compress.CompressGZip(ConvertHelper.ObjectToByteArray(value)), data.FileLocation); } }); }
public static void Insert <T>(string key, T value, string filelocation) { Interlocked.Increment(ref Cache.counter); SimpleObject simpleObject = new SimpleObject { Key = key, Value = value, FileLocation = filelocation }; //Add to cache Cache.CacheDic[filelocation + key] = simpleObject; ThreadPool.QueueUserWorkItem( state => Storage.WritetoStorage(simpleObject.Key, Compress.CompressGZip(ConvertHelper.ObjectToByteArray(value)), simpleObject.FileLocation)); }