• Home
  • Raw
  • Download

Lines Matching +full:cache +full:- +full:to

2  * libwebsockets - small server side websockets and web server implementation
4 * Copyright (C) 2010 - 2021 Andy Green <andy@warmcat.com>
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 #include <private-lib-core.h>
26 #include "private-lib-misc-cache-ttl.h"
37 lws_start_foreach_dll_safe(struct lws_dll2 *, d, d1, results_owner->head) { in lws_cache_clear_matches()
46 lws_cache_schedule(struct lws_cache_ttl_lru *cache, sul_cb_t cb, lws_usec_t e) in lws_cache_schedule() argument
48 lwsl_cache("%s: %s schedule %llu\n", __func__, cache->info.name, in lws_cache_schedule()
51 lws_sul_schedule(cache->info.cx, cache->info.tsi, &cache->sul, cb, in lws_cache_schedule()
52 e - lws_now_usecs()); in lws_cache_schedule()
56 lws_cache_write_through(struct lws_cache_ttl_lru *cache, in lws_cache_write_through() argument
60 struct lws_cache_ttl_lru *levels[LWS_CACHE_MAX_LEVELS], *c = cache; in lws_cache_write_through()
63 lws_cache_item_remove(cache, specific_key); in lws_cache_write_through()
69 c = c->info.parent; in lws_cache_write_through()
72 /* starting from outermost cache level */ in lws_cache_write_through()
75 n--; in lws_cache_write_through()
76 r = levels[n]->info.ops->write(levels[n], specific_key, in lws_cache_write_through()
84 * We want to make a list of unique keys that exist at any cache level
91 lws_cache_lookup(struct lws_cache_ttl_lru *cache, const char *wildcard_key, in lws_cache_lookup() argument
94 struct lws_cache_ttl_lru *l1 = cache; in lws_cache_lookup()
104 lws_strncpy(&meta_key[1], wildcard_key, sizeof(meta_key) - 2); in lws_cache_lookup()
110 if (!l1->info.ops->get(l1, meta_key, pdata, psize)) in lws_cache_lookup()
114 * No, we have to do the actual lookup work in the backing store layer in lws_cache_lookup()
115 * to get results for this... in lws_cache_lookup()
118 while (cache->info.parent) in lws_cache_lookup()
119 cache = cache->info.parent; in lws_cache_lookup()
121 if (cache->info.ops->lookup(cache, wildcard_key, &results_owner)) { in lws_cache_lookup()
131 * Scan the results, we want to know how big a payload it needs in in lws_cache_lookup()
132 * the cache, and we want to know the earliest expiry of any of the in lws_cache_lookup()
133 * component parts, so the meta cache entry for these results can be in lws_cache_lookup()
141 sum += m->tag_size + 1; in lws_cache_lookup()
143 if (m->expiry && (!expiry || expiry < m->expiry)) in lws_cache_lookup()
144 expiry = m->expiry; in lws_cache_lookup()
167 lws_ser_wu32be(p, (uint32_t)m->payload_size); in lws_cache_lookup()
170 lws_ser_wu32be(p, (uint32_t)m->tag_size); in lws_cache_lookup()
174 memcpy(p, &m[1], m->tag_size + 1); in lws_cache_lookup()
175 p += m->tag_size + 1; in lws_cache_lookup()
183 * with its expiry set to the earliest of the results, and copy it in in lws_cache_lookup()
187 n = l1->info.ops->write(l1, meta_key, temp, sum, expiry, (void **)&p); in lws_cache_lookup()
194 /* point to the results in L1 */ in lws_cache_lookup()
203 lws_cache_item_get(struct lws_cache_ttl_lru *cache, const char *specific_key, in lws_cache_item_get() argument
206 while (cache) { in lws_cache_item_get()
207 if (!cache->info.ops->get(cache, specific_key, pdata, psize)) { in lws_cache_item_get()
212 cache = cache->info.parent; in lws_cache_item_get()
219 lws_cache_expunge(struct lws_cache_ttl_lru *cache) in lws_cache_expunge() argument
223 while (cache) { in lws_cache_expunge()
224 ret |= cache->info.ops->expunge(cache); in lws_cache_expunge()
226 cache = cache->info.parent; in lws_cache_expunge()
233 lws_cache_item_remove(struct lws_cache_ttl_lru *cache, const char *wildcard_key) in lws_cache_item_remove() argument
235 while (cache) { in lws_cache_item_remove()
236 if (cache->info.ops->invalidate(cache, wildcard_key)) in lws_cache_item_remove()
239 cache = cache->info.parent; in lws_cache_item_remove()
246 lws_cache_footprint(struct lws_cache_ttl_lru *cache) in lws_cache_footprint() argument
248 return cache->current_footprint; in lws_cache_footprint()
252 lws_cache_debug_dump(struct lws_cache_ttl_lru *cache) in lws_cache_debug_dump() argument
255 if (cache->info.ops->debug_dump) in lws_cache_debug_dump()
256 cache->info.ops->debug_dump(cache); in lws_cache_debug_dump()
263 if (!walk_ctx->size) in lws_cache_results_walk()
266 walk_ctx->payload_len = lws_ser_ru32be(walk_ctx->ptr); in lws_cache_results_walk()
267 walk_ctx->tag_len = lws_ser_ru32be(walk_ctx->ptr + 4); in lws_cache_results_walk()
268 walk_ctx->tag = walk_ctx->ptr + 8; in lws_cache_results_walk()
270 walk_ctx->ptr += walk_ctx->tag_len + 1 + 8; in lws_cache_results_walk()
271 walk_ctx->size -= walk_ctx->tag_len + 1 + 8; in lws_cache_results_walk()
280 assert(info->ops); in lws_cache_create()
281 assert(info->name); in lws_cache_create()
282 assert(info->ops->create); in lws_cache_create()
284 return info->ops->create(info); in lws_cache_create()
290 lws_cache_ttl_lru_t *cache = *_cache; in lws_cache_destroy() local
292 if (!cache) in lws_cache_destroy()
295 assert(cache->info.ops->destroy); in lws_cache_destroy()
297 lws_sul_cancel(&cache->sul); in lws_cache_destroy()
299 cache->info.ops->destroy(_cache); in lws_cache_destroy()