MCPcopy Index your code
hub / github.com/ByteStorage/FlyDB / Keys

Method Keys

structure/string.go:315–335  ·  view source on GitHub ↗

Keys returns all keys matching pattern

(regx string)

Source from the content-addressed store, hash-verified

313
314// Keys returns all keys matching pattern
315func (s *StringStructure) Keys(regx string) ([]string, error) {
316 toRegexp := convertToRegexp(regx)
317 compile, err := regexp.Compile(toRegexp)
318 if err != nil {
319 return nil, err
320 }
321 var keys []string
322 byteKeys := s.db.GetListKeys()
323 for _, key := range byteKeys {
324 if compile.MatchString(string(key)) {
325 // check if key is expired
326 _, err := s.Get(string(key))
327 if err != nil {
328 continue
329 }
330 keys = append(keys, string(key))
331 }
332
333 }
334 return keys, nil
335}
336
337// Exists checks if a key exists
338func (s *StringStructure) Exists(key string) (bool, error) {

Callers

nothing calls this directly

Calls 3

GetMethod · 0.95
convertToRegexpFunction · 0.85
GetListKeysMethod · 0.80

Tested by

no test coverage detected