res_sorcery_memory_cache: Add support for a full backend cache.

This change introduces the configuration option 'full_backend_cache'
which changes the cache to be a full mirror of the backend instead
of a per-object cache. This allows all sorcery retrieval operations
to be carried out against it and is useful for object types which
are used in a "retrieve all" or "retrieve some" pattern.

ASTERISK-25625 #close

Change-Id: Ie2993487e9c19de563413ad5561c7403b48caab5
This commit is contained in:
Joshua Colp
2015-12-05 12:01:55 -04:00
parent 14b41115e3
commit 59d5bb0613
4 changed files with 995 additions and 61 deletions

View File

@@ -68,6 +68,14 @@ res_pjsip
- A TIMER statistic for the RTT time for each qualified contact, e.g.:
PJSIP.contacts.alice@@127.0.0.1:5061.rtt
res_sorcery_memory_cache
------------------------
* A new caching strategy, full_backend_cache, has been added which caches
all stored objects in the backend. When enabled all objects will be
expired or go stale according to the configuration. As well when enabled
all retrieval operations will be performed against the cache instead of
the backend.
func_callerid
-------------------
* CALLERID(pres) is now documented as a valid alternative to setting both

View File

@@ -1897,7 +1897,7 @@ void *ast_sorcery_retrieve_by_fields(const struct ast_sorcery *sorcery, const ch
}
}
if ((flags & AST_RETRIEVE_FLAG_MULTIPLE) || !object) {
if (((flags & AST_RETRIEVE_FLAG_MULTIPLE) && (!ao2_container_count(object) || !wizard->caching)) || !object) {
continue;
}
@@ -1935,6 +1935,10 @@ struct ao2_container *ast_sorcery_retrieve_by_regex(const struct ast_sorcery *so
}
wizard->wizard->callbacks.retrieve_regex(sorcery, wizard->data, object_type->name, objects, regex);
if (wizard->caching && ao2_container_count(objects)) {
break;
}
}
AST_VECTOR_RW_UNLOCK(&object_type->wizards);

View File

@@ -465,7 +465,7 @@ static int load_module(void)
ast_sorcery_object_field_register(ast_sip_get_sorcery(), "identify", "type", "", OPT_NOOP_T, 0, 0);
ast_sorcery_object_field_register(ast_sip_get_sorcery(), "identify", "endpoint", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ip_identify_match, endpoint_name));
ast_sorcery_object_field_register_custom(ast_sip_get_sorcery(), "identify", "match", "", ip_identify_match_handler, match_to_str, match_to_var_list, 0, 0);
ast_sorcery_reload_object(ast_sip_get_sorcery(), "identify");
ast_sorcery_load_object(ast_sip_get_sorcery(), "identify");
ast_sip_register_endpoint_identifier_with_name(&ip_identifier, "ip");
ast_sip_register_endpoint_formatter(&endpoint_identify_formatter);

File diff suppressed because it is too large Load Diff