[skip ci] Add comment for exported funcs in mem_key.go (#11877)

Signed-off-by: shaoyue.chen <shaoyue.chen@zilliz.com>
This commit is contained in:
shaoyue 2021-11-16 13:23:10 +08:00 committed by GitHub
parent 6322eb31e7
commit 53c29088b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,6 +42,7 @@ type memoryKVItem struct {
key, value string key, value string
} }
// Less returns true if the item is less than the given one.
func (s memoryKVItem) Less(than btree.Item) bool { func (s memoryKVItem) Less(than btree.Item) bool {
return s.key < than.(memoryKVItem).key return s.key < than.(memoryKVItem).key
} }
@ -58,6 +59,7 @@ func (kv *MemoryKV) Load(key string) (string, error) {
return item.(memoryKVItem).value, nil return item.(memoryKVItem).value, nil
} }
// LoadWithDefault loads an object with @key. If the object does not exist, @defaultValue will be returned.
func (kv *MemoryKV) LoadWithDefault(key, defaultValue string) string { func (kv *MemoryKV) LoadWithDefault(key, defaultValue string) string {
kv.RLock() kv.RLock()
defer kv.RUnlock() defer kv.RUnlock()
@ -69,6 +71,7 @@ func (kv *MemoryKV) LoadWithDefault(key, defaultValue string) string {
return item.(memoryKVItem).value return item.(memoryKVItem).value
} }
// LoadRange loads objects with range @startKey to @endKey with @limit number of objects.
func (kv *MemoryKV) LoadRange(key, endKey string, limit int) ([]string, []string, error) { func (kv *MemoryKV) LoadRange(key, endKey string, limit int) ([]string, []string, error) {
kv.RLock() kv.RLock()
defer kv.RUnlock() defer kv.RUnlock()