Documentation ¶
Index ¶
- func NewCacheWrapToDBHandle(c Cache, innerDb protocol.DBHandle, l protocol.Logger) protocol.DBHandle
- func QuickSort(arr []uint64) []uint64
- type Cache
- type CacheWrapToDBHandle
- func (c *CacheWrapToDBHandle) Close() error
- func (c *CacheWrapToDBHandle) CompactRange(start, limit []byte) error
- func (c *CacheWrapToDBHandle) Delete(key []byte) error
- func (c *CacheWrapToDBHandle) Get(key []byte) ([]byte, error)
- func (c *CacheWrapToDBHandle) GetDbType() string
- func (c *CacheWrapToDBHandle) GetWriteBatchSize() uint64
- func (c *CacheWrapToDBHandle) Has(key []byte) (bool, error)
- func (c *CacheWrapToDBHandle) NewIteratorWithPrefix(prefix []byte) (protocol.Iterator, error)
- func (c *CacheWrapToDBHandle) NewIteratorWithRange(start []byte, limit []byte) (protocol.Iterator, error)
- func (c *CacheWrapToDBHandle) Put(key []byte, value []byte) error
- func (c *CacheWrapToDBHandle) WriteBatch(batch protocol.StoreBatcher, sync bool) error
- type StoreCacheMgr
- func (mgr *StoreCacheMgr) AddBlock(blockHeight uint64, updateBatch protocol.StoreBatcher)
- func (mgr *StoreCacheMgr) Clear()
- func (mgr *StoreCacheMgr) DelBlock(blockHeight uint64)
- func (mgr *StoreCacheMgr) Get(key string) ([]byte, bool)
- func (mgr *StoreCacheMgr) GetBatch(height uint64) (protocol.StoreBatcher, error)
- func (mgr *StoreCacheMgr) Has(key string) (bool, bool)
- func (mgr *StoreCacheMgr) KVRange(startKey []byte, endKey []byte) (map[string][]byte, error)
- func (mgr *StoreCacheMgr) LockForFlush()
- func (mgr *StoreCacheMgr) UnLockFlush()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CacheWrapToDBHandle ¶
type CacheWrapToDBHandle struct {
// contains filtered or unexported fields
}
func (*CacheWrapToDBHandle) CompactRange ¶
func (c *CacheWrapToDBHandle) CompactRange(start, limit []byte) error
compacts the underlying DB for the given key range
func (*CacheWrapToDBHandle) Delete ¶
func (c *CacheWrapToDBHandle) Delete(key []byte) error
delete key/value from cache and db
func (*CacheWrapToDBHandle) Get ¶
func (c *CacheWrapToDBHandle) Get(key []byte) ([]byte, error)
get value by key from cache and db
func (*CacheWrapToDBHandle) GetDbType ¶
func (c *CacheWrapToDBHandle) GetDbType() string
get db type from db
func (*CacheWrapToDBHandle) GetWriteBatchSize ¶
func (c *CacheWrapToDBHandle) GetWriteBatchSize() uint64
func (*CacheWrapToDBHandle) Has ¶
func (c *CacheWrapToDBHandle) Has(key []byte) (bool, error)
check key whether exist in cache and db
func (*CacheWrapToDBHandle) NewIteratorWithPrefix ¶
func (c *CacheWrapToDBHandle) NewIteratorWithPrefix(prefix []byte) (protocol.Iterator, error)
returns an iterator that contains all the key-values with given prefix
func (*CacheWrapToDBHandle) NewIteratorWithRange ¶
func (c *CacheWrapToDBHandle) NewIteratorWithRange(start []byte, limit []byte) (protocol.Iterator, error)
return iterator from db that contains all the key-values between given key ranges start is included in the results and limit is excluded.
func (*CacheWrapToDBHandle) Put ¶
func (c *CacheWrapToDBHandle) Put(key []byte, value []byte) error
set key/value include cache and db
func (*CacheWrapToDBHandle) WriteBatch ¶
func (c *CacheWrapToDBHandle) WriteBatch(batch protocol.StoreBatcher, sync bool) error
write a batch to cache and db
type StoreCacheMgr ¶
StoreCacheMgr provide handle to cache instances
func NewStoreCacheMgr ¶
func NewStoreCacheMgr(chainId string, blockWriteBufferSize int, logger protocol.Logger) *StoreCacheMgr
NewStoreCacheMgr construct a new `StoreCacheMgr` with given chainId
func (*StoreCacheMgr) AddBlock ¶
func (mgr *StoreCacheMgr) AddBlock(blockHeight uint64, updateBatch protocol.StoreBatcher)
AddBlock cache a block with given block height and update batch
func (*StoreCacheMgr) DelBlock ¶
func (mgr *StoreCacheMgr) DelBlock(blockHeight uint64)
DelBlock delete block for the given block height
func (*StoreCacheMgr) Get ¶
func (mgr *StoreCacheMgr) Get(key string) ([]byte, bool)
Get returns value if the key in cache, or returns nil if none exists.
func (*StoreCacheMgr) GetBatch ¶
func (mgr *StoreCacheMgr) GetBatch(height uint64) (protocol.StoreBatcher, error)
根据块高,返回 块对应的cache
func (*StoreCacheMgr) Has ¶
func (mgr *StoreCacheMgr) Has(key string) (bool, bool)
Has returns true if the key in cache, or returns false if none exists. return isDelete,isExist 如果这个key 对应value 是 nil,说明这个key被删除了 所以查找到第一个key,要判断 这个key 是否是被删除的
func (*StoreCacheMgr) LockForFlush ¶
func (mgr *StoreCacheMgr) LockForFlush()
LockForFlush used to lock cache until all cache item be flushed to db
func (*StoreCacheMgr) UnLockFlush ¶
func (mgr *StoreCacheMgr) UnLockFlush()
UnLockFlush used to unlock cache by release all semaphore