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); }
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); }
internal LockHolder(GlobalReaderWriterLock theLock, ReadOrWrite rw) { _lock = theLock; switch (rw) { case ReadOrWrite.Read: _lock.AcquireReadLock(); break; case ReadOrWrite.Write: _lock.AcquireWriteLock(); break; } _haveLock = rw; }