From 55daecb7bcce747efcb888c22717d7bc5a7a1900 Mon Sep 17 00:00:00 2001 From: DanB Date: Thu, 22 Feb 2018 14:53:01 +0100 Subject: [PATCH] Updating ltcache with groups support --- cache/cache.go | 2 +- cache/cache_store.go | 9 ++++----- glide.lock | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cache/cache.go b/cache/cache.go index cf654e022..61b1e3dd2 100755 --- a/cache/cache.go +++ b/cache/cache.go @@ -107,7 +107,7 @@ func Set(key string, value interface{}, commit bool, transID string) { cacheMux.Lock() defer cacheMux.Unlock() } - cache.Put(key, value) + cache.Put(key, value, nil) //log.Println("ADD: ", key) } else { transBufMux.Lock() diff --git a/cache/cache_store.go b/cache/cache_store.go index 1d4771a13..7886ab934 100755 --- a/cache/cache_store.go +++ b/cache/cache_store.go @@ -27,7 +27,7 @@ import ( ) type cacheStore interface { - Put(string, interface{}) + Put(string, interface{}, []string) Get(string) (interface{}, bool) Delete(string) DeletePrefix(string) @@ -64,8 +64,8 @@ func (cs cacheLRUTTL) cacheInstance(instID string) (c *ltcache.Cache) { return } -func (cs cacheLRUTTL) Put(key string, value interface{}) { - cs.cacheInstance(key[:PREFIX_LEN]).Set(key[PREFIX_LEN:], value) +func (cs cacheLRUTTL) Put(key string, value interface{}, grpIDs []string) { + cs.cacheInstance(key[:PREFIX_LEN]).Set(key[PREFIX_LEN:], value, grpIDs) } func (cs cacheLRUTTL) Get(key string) (interface{}, bool) { @@ -92,8 +92,7 @@ func (cs cacheLRUTTL) CountEntriesForPrefix(prefix string) (cnt int) { func (cs cacheLRUTTL) GetKeysForPrefix(prefix string) (keys []string) { prefix, key := prefix[:PREFIX_LEN], prefix[PREFIX_LEN:] if c, ok := cs[prefix]; ok { - for _, ifKey := range c.Keys() { - iterKey := ifKey.(string) + for _, iterKey := range c.Items() { if len(key) == 0 || strings.HasPrefix(iterKey, key) { keys = append(keys, prefix+iterKey) } diff --git a/glide.lock b/glide.lock index c52298808..801517847 100644 --- a/glide.lock +++ b/glide.lock @@ -16,7 +16,7 @@ imports: - name: github.com/cgrates/kamevapi version: e4dfe7d6cb5bb0872111fe7d61af0e1a19eda485 - name: github.com/cgrates/ltcache - version: 74beef0471a1e04ec8c95b5459086a9308dfff84 + version: e96891e9c23f8b15dfd5bfbb22ac05aacaf83860 - name: github.com/cgrates/osipsdagram version: 3d6beed663452471dec3ca194137a30d379d9e8f - name: github.com/cgrates/radigo