From 54e0d3b2d26e291211fe0ce2b1ef174884baeb97 Mon Sep 17 00:00:00 2001 From: DanB Date: Tue, 13 Sep 2022 18:24:02 +0200 Subject: [PATCH] Adding CacheSv1.GetItem method --- engine/caches.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/engine/caches.go b/engine/caches.go index b76a503f1..661d64581 100644 --- a/engine/caches.go +++ b/engine/caches.go @@ -35,6 +35,9 @@ var Cache *CacheS func init() { Cache = NewCacheS(config.CgrConfig(), nil, nil) + + // Register objects for cache replication/remotes + // AttributeS gob.Register(new(AttributeProfile)) gob.Register(new(AttributeProfileWithAPIOpts)) // Threshold @@ -69,7 +72,6 @@ func init() { // ActionProfiles gob.Register(new(ActionProfile)) gob.Register(new(ActionProfileWithAPIOpts)) - // StatMetrics gob.Register(new(StatASR)) gob.Register(new(StatACD)) @@ -81,7 +83,7 @@ func init() { gob.Register(new(StatSum)) gob.Register(new(StatAverage)) gob.Register(new(StatDistinct)) - + // others gob.Register([]interface{}{}) gob.Register([]map[string]interface{}{}) gob.Register(map[string]interface{}{}) @@ -253,6 +255,17 @@ func (chS *CacheS) V1HasItem(_ *context.Context, args *utils.ArgsGetCacheItemWit return } +// V1GetItem returns a single item from the cache +func (chS *CacheS) V1GetItem(_ *context.Context, args *utils.ArgsGetCacheItemWithAPIOpts, + reply *interface{}) (err error) { + itmIface, has := chS.tCache.Get(args.CacheID, args.ItemID) + if !has { + return utils.ErrNotFound + } + *reply = itmIface + return +} + func (chS *CacheS) V1GetItemExpiryTime(_ *context.Context, args *utils.ArgsGetCacheItemWithAPIOpts, reply *time.Time) (err error) { expTime, has := chS.tCache.GetItemExpiryTime(args.CacheID, args.ItemID)