コード例 #1
0
        public static ServiceStack.Redis.IRedisClient GetRedisClient(ReadOrWrite rw)
        {
            ServiceStack.Redis.IRedisClient client = null;
            switch (rw)
            {
            //读写
            case ReadOrWrite.Write:
                client = RadisManager.GetClient();
                break;

            //只读
            case ReadOrWrite.Read:
                client = RadisManager.GetReadOnlyClient();
                break;
            }

            return(client);
        }
コード例 #2
0
 private void Cleanup(bool disposing)
 {
     switch (_haveLock)
     {
         case ReadOrWrite.Read:
             _lock.ReleaseReadLock();
             break;
         case ReadOrWrite.Write:
             _lock.ReleaseWriteLock();
             break;
         default:
             // already ran cleanup, just return immediately instead of re-disposing below
             return;
     }
     _haveLock = ReadOrWrite.None;
     _lock.Dispose();
     _lock = null;
     if (disposing)
         GC.SuppressFinalize(this);
 }
コード例 #3
0
 internal LockHolder(GlobalReaderWriterLock theLock, ReadOrWrite rw)
 {
     _lock = theLock;
     switch (rw)
     {
         case ReadOrWrite.Read:
             _lock.AcquireReadLock();
             break;
         case ReadOrWrite.Write:
             _lock.AcquireWriteLock();
             break;
     }
     _haveLock = rw;
 }