Adding CacheSv1.GetItem method

This commit is contained in:
DanB
2022-09-13 18:24:02 +02:00
parent 18c5e3d8bc
commit 54e0d3b2d2

View File

@@ -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)