store/memory: small fixups for flow usage
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
42800fa247
commit
1e43122660
@ -74,13 +74,17 @@ func (m *memoryStore) list(prefix string, limit, offset uint) []string {
|
||||
i := 0
|
||||
|
||||
for k := range allItems {
|
||||
if !strings.HasPrefix(k, prefix+"/") {
|
||||
if !strings.HasPrefix(k, prefix) {
|
||||
continue
|
||||
}
|
||||
allKeys[i] = strings.TrimPrefix(k, prefix+"/")
|
||||
if prefix == "" {
|
||||
allKeys[i] = strings.TrimPrefix(k, "/")
|
||||
} else {
|
||||
allKeys[i] = strings.TrimPrefix(k, prefix)
|
||||
}
|
||||
allKeys[i] = strings.TrimPrefix(allKeys[i], "/")
|
||||
i++
|
||||
}
|
||||
|
||||
if limit != 0 || offset != 0 {
|
||||
sort.Slice(allKeys, func(i, j int) bool { return allKeys[i] < allKeys[j] })
|
||||
sort.Slice(allKeys, func(i, j int) bool { return allKeys[i] < allKeys[j] })
|
||||
@ -137,6 +141,9 @@ func (m *memoryStore) Write(ctx context.Context, key string, val interface{}, op
|
||||
if options.Namespace == "" {
|
||||
options.Namespace = m.opts.Namespace
|
||||
}
|
||||
if options.TTL == 0 {
|
||||
options.TTL = cache.NoExpiration
|
||||
}
|
||||
|
||||
key = m.key(options.Namespace, key)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user