Mohammad Habbab
unread,Sep 22, 2012, 4:30:18 AM9/22/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to servic...@googlegroups.com
Code:
var Objects_key = AssembleKey_CommentObjects(streamId);
var PublicEvents_key = AssembleKey_PublicEventstream(streamId);
var Lock_key = AssembleKey_StreamLock(streamId);
var PrivateEvents_key = AssembleKey_ParticipantEventStream(streamUserId,streamId);
var Ids_key = AssembleKey_CommentIds(streamId);
using (cacheClient.AcquireLock(Lock_key))
{
var tempclient = cacheClient.GetTypedClient<Comment>();
long time_score = streamObject.CreationTime.Value.Ticks;
tempclient.Sets[Objects_key].Add(streamObject);
cacheClient.Sets[Ids_key].Add(streamObject.Id);
string event_message = "Added:" + streamObject.Id;
cacheClient.AddItemToSortedSet(PublicEvents_key, event_message, time_score);
cacheClient.AddItemToSortedSet(PrivateEvents_key, event_message, time_score);
}
if (OnStreamWriteSuccess != null)
OnStreamWriteSuccess(streamId, streamUserId, streamObject);
The code above is accessed by multiple clients on multiple threads. however the operations are serialized in the lock-surrounding section. For reason that i'm not aware of, the Set Operation sometimes while adding removes the set , if it was already there, all together, and other times it just does the add operation as it's intended to be.
Extra Info:
1- The class containing this code is initialized with a client [CacheClient] that it gets from a PooledRedisClientManager or a BasicRedisClientManager [the problem occurs on both]. and the class implements the IDisposable interface where it disposes the connection.
2- The App has a Singletone IRedisClientManager (which was mentioned in point-1) which provides a GetClient() call which is called on this class initialization.