Updating ltcache with groups support

This commit is contained in:
DanB
2018-02-22 14:53:01 +01:00
parent 30400e4c9c
commit 55daecb7bc
3 changed files with 6 additions and 7 deletions

2
cache/cache.go vendored
View File

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

View File

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

2
glide.lock generated
View File

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