MCPcopy Create free account
hub / github.com/distributedio/titan / RandomKey

Function RandomKey

command/keys.go:348–358  ·  view source on GitHub ↗

RandomKey returns a random key from the currently selected database

(ctx *Context, txn *db.Transaction)

Source from the content-addressed store, hash-verified

346
347// RandomKey returns a random key from the currently selected database
348func RandomKey(ctx *Context, txn *db.Transaction) (OnCommit, error) {
349 kv := txn.Kv()
350 key, err := kv.RandomKey()
351 if err != nil {
352 return nil, errors.New("ERR " + err.Error())
353 }
354 if key == nil {
355 return NullBulkString(ctx.Out), nil
356 }
357 return BulkString(ctx.Out, string(key)), nil
358}
359
360// Touch alters the last access time of a key(s)
361func Touch(ctx *Context, txn *db.Transaction) (OnCommit, error) {

Callers

nothing calls this directly

Calls 5

NullBulkStringFunction · 0.85
BulkStringFunction · 0.85
KvMethod · 0.80
RandomKeyMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected