16 #include "keycaches.h"
29 while ((element= it++))
31 if (element->cmp(name, length))
42 void NAMED_ILIST::delete_elements(
void (*free_element)(
const char *name, uchar*))
45 DBUG_ENTER(
"NAMED_ILIST::delete_elements");
46 while ((element=
get()))
48 (*free_element)(element->name, element->data);
57 LEX_STRING default_key_cache_base= {C_STRING_WITH_LEN(
"default")};
63 if (!cache_name || ! cache_name->length)
64 cache_name= &default_key_cache_base;
65 return ((
KEY_CACHE*) find_named(&key_caches,
66 cache_name->str, cache_name->length, 0));
69 KEY_CACHE *create_key_cache(
const char *name, uint length)
72 DBUG_ENTER(
"create_key_cache");
73 DBUG_PRINT(
"enter",(
"name: %.*s", length, name));
76 MYF(MY_ZEROFILL | MY_WME))))
78 if (!
new NAMED_ILINK(&key_caches, name, length, (uchar*) key_cache))
91 key_cache->param_block_size= dflt_key_cache_var.param_block_size;
92 key_cache->param_division_limit= dflt_key_cache_var.param_division_limit;
93 key_cache->param_age_threshold= dflt_key_cache_var.param_age_threshold;
96 DBUG_RETURN(key_cache);
100 KEY_CACHE *get_or_create_key_cache(
const char *name, uint length)
105 key_cache_name.str= (
char *) name;
106 key_cache_name.length= length;
107 if (!(key_cache= get_key_cache(&key_cache_name)))
108 key_cache= create_key_cache(name, length);
113 void free_key_cache(
const char *name,
KEY_CACHE *key_cache)
115 end_key_cache(key_cache, 1);
120 bool process_key_caches(process_key_cache_t func)
125 while ((element= it++))
128 func(element->name, key_cache);