Beispiel #1
0
        public void Put(Span <byte> key, Span <byte> value)
        {
            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?");
            }

            _newMemCache.Put(key, value);
        }
        private void PutInternal(BatchOperation operation)
        {
            _dbLock.EnterWriteLock();

            try
            {
                MakeSurePutWorks();

                ulong sequenceNumber = _manifest.CurrentVersion.GetNextSequenceNumber();
                var   batch          = new WriteBatch
                {
                    Sequence = sequenceNumber,
                };
                batch.Operations.Add(operation);

                // Write to LOG here.
                _log?.WriteData(batch.EncodeBatch());
                _memCache.Put(batch);
            }
            finally
            {
                _dbLock.ExitWriteLock();
            }
        }