mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 05:09:54 +05:00
count keys on CachePush too
This commit is contained in:
@@ -114,6 +114,10 @@ func CachePush(key string, val interface{}) {
|
||||
if !found {
|
||||
elements = append(elements, val)
|
||||
}
|
||||
if _, ok := cache[key]; !ok {
|
||||
// only count if the key is not already there
|
||||
count(key)
|
||||
}
|
||||
cache[key] = timestampedValue{time.Now(), elements}
|
||||
} else {
|
||||
transactionBuffer = append(transactionBuffer, transactionItem{key: key, value: val, kind: KIND_ADP})
|
||||
@@ -174,18 +178,6 @@ func RemPrefixKey(prefix string) {
|
||||
}
|
||||
}
|
||||
|
||||
func GetAllEntries(prefix string) map[string]interface{} {
|
||||
mux.RLock()
|
||||
defer mux.RUnlock()
|
||||
result := make(map[string]interface{})
|
||||
for key, timestampedValue := range cache {
|
||||
if strings.HasPrefix(key, prefix) {
|
||||
result[key] = timestampedValue.value
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Delete all keys from cache
|
||||
func Flush() {
|
||||
mux.Lock()
|
||||
@@ -228,6 +220,18 @@ func descount(key string) {
|
||||
}
|
||||
}
|
||||
|
||||
func GetAllEntries(prefix string) map[string]interface{} {
|
||||
mux.RLock()
|
||||
defer mux.RUnlock()
|
||||
result := make(map[string]interface{})
|
||||
for key, timestampedValue := range cache {
|
||||
if strings.HasPrefix(key, prefix) {
|
||||
result[key] = timestampedValue.value
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func GetEntriesKeys(prefix string) (keys []string) {
|
||||
mux.RLock()
|
||||
defer mux.RUnlock()
|
||||
|
||||
Reference in New Issue
Block a user