public byte[] Get(Span <byte> key) { if (_manifest == null) { throw new InvalidOperationException("No manifest for database. Did you open it?"); } if (_newMemCache == null) { throw new InvalidOperationException("No current memory cache for database. Did you open it?"); } ResultStatus result = _newMemCache.Get(key); if (result.State == ResultState.Deleted || result.State == ResultState.Exist) { if (result.Data == ReadOnlySpan <byte> .Empty) { return(null); } return(result.Data.ToArray()); } result = _manifest.Get(key); if (result.Data == ReadOnlySpan <byte> .Empty) { return(null); } return(result.Data.ToArray()); }
public byte[] Get(Span <byte> key) { _dbLock.EnterReadLock(); try { if (_manifest == null) { throw new InvalidOperationException("No manifest for database. Did you open it?"); } if (_memCache == null) { throw new InvalidOperationException("No current memory cache for database. Did you open it?"); } ResultStatus result = _memCache.Get(key); if (result.State == ResultState.Deleted || result.State == ResultState.Exist) { if (result.Data == ReadOnlySpan <byte> .Empty) { return(null); } return(result.Data.ToArray()); } MemCache imm = _immutableMemCache; if (imm != null) { result = imm.Get(key); if (result.State == ResultState.Deleted || result.State == ResultState.Exist) { if (result.Data == ReadOnlySpan <byte> .Empty) { return(null); } return(result.Data.ToArray()); } } result = _manifest.Get(key); if (result.Data == ReadOnlySpan <byte> .Empty) { return(null); } return(result.Data.ToArray()); } finally { _dbLock.ExitReadLock(); } }