From f3ce00bc3fd2ef39609af8f00ed431c56bb6a280 Mon Sep 17 00:00:00 2001 From: DanB Date: Thu, 8 Mar 2018 10:21:42 +0100 Subject: [PATCH] CacheSv1.GetItemIDs API --- apier/v1/caches.go | 8 +++++++- engine/caches.go | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/apier/v1/caches.go b/apier/v1/caches.go index 7535e9372..73e32302a 100644 --- a/apier/v1/caches.go +++ b/apier/v1/caches.go @@ -33,8 +33,14 @@ type CacheSv1 struct { cacheS *engine.CacheS } -// GetItemExpiryTime re +// GetItemExpiryTime returns the expiryTime for an item func (chSv1 *CacheSv1) GetItemExpiryTime(args *engine.ArgsGetCacheItem, reply *time.Time) error { return chSv1.cacheS.V1GetItemExpiryTime(args, reply) } + +// GetItemExpiryTime returns the expiryTime for an item +func (chSv1 *CacheSv1) GetItemIDs(args *engine.ArgsGetCacheItemIDs, + reply *[]string) error { + return chSv1.cacheS.V1GetItemIDs(args, reply) +} diff --git a/engine/caches.go b/engine/caches.go index 1b1b526c3..94e9ee2fe 100644 --- a/engine/caches.go +++ b/engine/caches.go @@ -125,3 +125,18 @@ func (chS *CacheS) V1GetItemExpiryTime(args *ArgsGetCacheItem, } return } + +type ArgsGetCacheItemIDs struct { + CacheID string + ItemIDPrefix string +} + +func (chS *CacheS) V1GetItemIDs(args *ArgsGetCacheItemIDs, + reply *[]string) (err error) { + if itmIDs := Cache.GetItemIDs(args.CacheID, args.ItemIDPrefix); len(itmIDs) == 0 { + return utils.ErrNotFound + } else { + *reply = itmIDs + } + return +}