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) GetKeys(keys [][]byte) ([][]byte, error)
- 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 Cache ¶ added in v2.2.0
type Cache interface { // Get get key from cache or db // @Description: // @param key // @return []byte // @return error Get(key string) ([]byte, error) // Set set k/v // @Description: // @param key // @param entry // @return error Set(key string, entry []byte) error // Delete del k // @Description: // @param key // @return error Delete(key string) error // Reset set cache to initial state // @Description: // @return error Reset() error // Close close cache // @Description: // @return error Close() error }
Cache interface
@Description:
type CacheWrapToDBHandle ¶ added in v2.2.0
type CacheWrapToDBHandle struct {
// contains filtered or unexported fields
}
CacheWrapToDBHandle struct
@Description:
func (*CacheWrapToDBHandle) Close ¶ added in v2.2.0
func (c *CacheWrapToDBHandle) Close() error
Close close cache and db
@Description: @receiver c @return error
func (*CacheWrapToDBHandle) CompactRange ¶ added in v2.2.0
func (c *CacheWrapToDBHandle) CompactRange(start, limit []byte) error
CompactRange compacts the underlying DB for the given key range
@Description: @receiver c @param start @param limit @return error
func (*CacheWrapToDBHandle) Delete ¶ added in v2.2.0
func (c *CacheWrapToDBHandle) Delete(key []byte) error
Delete delete key/value from cache and db
@Description: @receiver c @param key @return error
func (*CacheWrapToDBHandle) Get ¶ added in v2.2.0
func (c *CacheWrapToDBHandle) Get(key []byte) ([]byte, error)
Get get value by key from cache and db
@Description: @receiver c @param key @return []byte @return error
func (*CacheWrapToDBHandle) GetDbType ¶ added in v2.2.0
func (c *CacheWrapToDBHandle) GetDbType() string
GetDbType get db type from db
@Description: @receiver c @return string
func (*CacheWrapToDBHandle) GetKeys ¶ added in v2.3.0
func (c *CacheWrapToDBHandle) GetKeys(keys [][]byte) ([][]byte, error)
GetKeys batch get key's value; if not found , batch get from db then refill them in cache @Description: @receiver c @param keys @return [][]byte @return error
func (*CacheWrapToDBHandle) GetWriteBatchSize ¶ added in v2.2.0
func (c *CacheWrapToDBHandle) GetWriteBatchSize() uint64
GetWriteBatchSize not implement , will panic
@Description: @receiver c @return uint64
func (*CacheWrapToDBHandle) Has ¶ added in v2.2.0
func (c *CacheWrapToDBHandle) Has(key []byte) (bool, error)
Has check key whether exist in cache and db
@Description: @receiver c @param key @return bool @return error
func (*CacheWrapToDBHandle) NewIteratorWithPrefix ¶ added in v2.2.0
func (c *CacheWrapToDBHandle) NewIteratorWithPrefix(prefix []byte) (protocol.Iterator, error)
NewIteratorWithPrefix returns an iterator that contains all the key-values with given prefix
@Description: @receiver c @param prefix @return protocol.Iterator @return error
func (*CacheWrapToDBHandle) NewIteratorWithRange ¶ added in v2.2.0
func (c *CacheWrapToDBHandle) NewIteratorWithRange(start []byte, limit []byte) (protocol.Iterator, error)
NewIteratorWithRange return iterator from db that contains all the key-values between given key ranges start is included in the results and limit is excluded.
@Description: @receiver c @param start @param limit @return protocol.Iterator @return error
func (*CacheWrapToDBHandle) Put ¶ added in v2.2.0
func (c *CacheWrapToDBHandle) Put(key []byte, value []byte) error
Put set key/value include cache and db @Description: @receiver c @param key @param value @return error
func (*CacheWrapToDBHandle) WriteBatch ¶ added in v2.2.0
func (c *CacheWrapToDBHandle) WriteBatch(batch protocol.StoreBatcher, sync bool) error
WriteBatch write a batch to cache and db
@Description: @receiver c @param batch @param sync @return error
type StoreCacheMgr ¶
StoreCacheMgr provide handle to cache instances
@Description:
func NewStoreCacheMgr ¶
func NewStoreCacheMgr(chainId string, blockWriteBufferSize int, logger protocol.Logger) *StoreCacheMgr
NewStoreCacheMgr construct a new `StoreCacheMgr` with given chainId
@Description: @param chainId @param blockWriteBufferSize @param logger @return *StoreCacheMgr
func (*StoreCacheMgr) AddBlock ¶
func (mgr *StoreCacheMgr) AddBlock(blockHeight uint64, updateBatch protocol.StoreBatcher)
AddBlock cache a block with given block height and update batch
@Description: @receiver mgr @param blockHeight @param updateBatch
func (*StoreCacheMgr) Clear ¶
func (mgr *StoreCacheMgr) Clear()
Clear 清除缓存,目前未做任何清除操作
@Description: @receiver mgr
func (*StoreCacheMgr) DelBlock ¶
func (mgr *StoreCacheMgr) DelBlock(blockHeight uint64)
DelBlock delete block for the given block height
@Description: @receiver mgr @param blockHeight
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.
@Description: @receiver mgr @param key @return []byte @return bool
func (*StoreCacheMgr) GetBatch ¶ added in v2.2.0
func (mgr *StoreCacheMgr) GetBatch(height uint64) (protocol.StoreBatcher, error)
GetBatch 根据块高,返回 块对应的cache
@Description: @receiver mgr @param height @return protocol.StoreBatcher @return error
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. 如果这个key 对应value 是 nil,说明这个key被删除了 所以查找到第一个key,要判断 这个key 是否是被删除的
@Description: @receiver mgr @param key @return bool isDelete @return bool isExist
func (*StoreCacheMgr) KVRange ¶ added in v2.2.0
KVRange get data from mgr , [startKey,endKey)
@Description: @receiver mgr @param startKey @param endKey @return map[string][]byte @return error
func (*StoreCacheMgr) LockForFlush ¶
func (mgr *StoreCacheMgr) LockForFlush()
LockForFlush used to lock cache until all cache item be flushed to db
@Description: @receiver mgr
func (*StoreCacheMgr) UnLockFlush ¶
func (mgr *StoreCacheMgr) UnLockFlush()
UnLockFlush used to unlock cache by release all semaphore
@Description: @receiver mgr