MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / LKeys

Method LKeys

tx_list.go:435–461  ·  view source on GitHub ↗

LKeys find all keys matching a given pattern

(bucket, pattern string, f func(key string) bool)

Source from the content-addressed store, hash-verified

433
434// LKeys find all keys matching a given pattern
435func (tx *Tx) LKeys(bucket, pattern string, f func(key string) bool) error {
436 if err := tx.checkTxIsClosed(); err != nil {
437 return err
438 }
439 b, err := tx.db.bucketMgr.GetBucket(DataStructureList, bucket)
440 if err != nil {
441 return err
442 }
443 var (
444 bucketId = b.Id
445 l *data.List
446 exist bool
447 )
448 if l, exist = tx.db.Index.List.exist(bucketId); !exist {
449 return ErrBucket
450 }
451
452 for key := range l.Items {
453 if tx.CheckExpire(bucket, []byte(key)) {
454 continue
455 }
456 if end, err := utils.MatchForRange(pattern, key, f); end || err != nil {
457 return err
458 }
459 }
460 return nil
461}
462
463func (tx *Tx) ExpireList(bucket string, key []byte, ttl uint32) error {
464 if err := tx.checkTxIsClosed(); err != nil {

Callers 2

txLKeysFunction · 0.80
testLKeysFunction · 0.80

Calls 5

checkTxIsClosedMethod · 0.95
CheckExpireMethod · 0.95
MatchForRangeFunction · 0.92
GetBucketMethod · 0.80
existMethod · 0.80

Tested by 1

txLKeysFunction · 0.64