From 0db4e8d62c15aa387a910d3a0e4bcc17fab982bf Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Wed, 5 Oct 2022 13:42:15 +0300 Subject: [PATCH] core: allow to perform storage search within given amount of DAO layers --- pkg/core/storage/memcached_store.go | 7 ++++++- pkg/core/storage/store.go | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/core/storage/memcached_store.go b/pkg/core/storage/memcached_store.go index 75e36dda5..f91c74fc4 100644 --- a/pkg/core/storage/memcached_store.go +++ b/pkg/core/storage/memcached_store.go @@ -301,7 +301,12 @@ func performSeek(ctx context.Context, ps Store, memRes []KeyValueExists, rng See } } } - ps.Seek(rng, mergeFunc) + if rng.SearchDepth == 0 || rng.SearchDepth > 1 { + if rng.SearchDepth > 1 { + rng.SearchDepth-- + } + ps.Seek(rng, mergeFunc) + } if !done && haveMem { loop: diff --git a/pkg/core/storage/store.go b/pkg/core/storage/store.go index caa8a4e73..0f2461bcd 100644 --- a/pkg/core/storage/store.go +++ b/pkg/core/storage/store.go @@ -59,6 +59,11 @@ type SeekRange struct { // whether seeking should be performed in a descending way. // Backwards can be safely combined with Prefix and Start. Backwards bool + // SearchDepth is the depth of Seek operation, denotes the number of cached + // DAO layers to perform search. Use 1 to fetch the latest changes from upper + // in-memory layer of cached DAO. Default 0 value denotes searching through + // the whole set of cached layers. + SearchDepth int } // ErrKeyNotFound is an error returned by Store implementations