-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
Thank you for this project!
I am stripping some code because I only need some parts, but now I do not understand some things. Given the following part:
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
Cache.CacheDictionary[filelocation + key] = simpleObject;
ThreadPool.QueueUserWorkItem(state =>
{
Storage.WriteToStorage(data.Key, Compress.CompressGZip(ConvertHelper.ObjectToByteArray(value)), data.FileLocation);
});
My questions:
- Why did you implement a sendQueue? The key after a Take() is used in the WriteToStorage. Why can't the key not be used directly?
- The above method adds the object to the cache but it is later deleted inside WriteToStorage. Is this wrong or did I miss an important part of code?
- Should the statement 'Interlocked.Decrement(ref Cache.counter);' not be after the thread.sleep inside WriteToStorage?
Best regards,
Evert
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels