started liases reverse mapping

This commit is contained in:
Radu Ioan Fericean
2015-09-04 13:49:35 +03:00
parent 2dbf8689b9
commit c2cb492cbe
3 changed files with 20 additions and 0 deletions

View File

@@ -578,6 +578,15 @@ func (ms *MapStorage) GetAlias(key string, skipCache bool) (al *Alias, err error
err = ms.ms.Unmarshal(values, &al.Values)
if err == nil {
cache2go.Cache(key, al.Values)
for _, v := range al.Values {
var existingKeys []string
rKey := utils.REVERSE_ALIASES_PREFIX + v.Alias
if x, err := cache2go.GetCached(rKey); err == nil {
existingKeys = x.([]string)
}
existingKeys = append(existingKeys, key)
cache2go.Cache(rKey, existingKeys)
}
}
} else {
return nil, utils.ErrNotFound

View File

@@ -682,6 +682,16 @@ func (rs *RedisStorage) GetAlias(key string, skipCache bool) (al *Alias, err err
err = rs.ms.Unmarshal(values, &al.Values)
if err == nil {
cache2go.Cache(key, al.Values)
// cache reverse alias
for _, v := range al.Values {
var existingKeys []string
rKey := utils.REVERSE_ALIASES_PREFIX + v.Alias
if x, err := cache2go.GetCached(rKey); err == nil {
existingKeys = x.([]string)
}
existingKeys = append(existingKeys, key)
cache2go.Cache(rKey, existingKeys)
}
}
}
return

View File

@@ -176,6 +176,7 @@ const (
PUBSUB_SUBSCRIBERS_PREFIX = "pss_"
USERS_PREFIX = "usr_"
ALIASES_PREFIX = "als_"
REVERSE_ALIASES_PREFIX = "rls_"
CDR_STATS_PREFIX = "cst_"
TEMP_DESTINATION_PREFIX = "tmp_"
LOG_CALL_COST_PREFIX = "cco_"