libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
lws-cache-ttl.h
Go to the documentation of this file.
1/*
2 * libwebsockets - small server side websockets and web server implementation
3 *
4 * Copyright (C) 2010 - 2021 Andy Green <andy@warmcat.com>
5 *
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
8 * deal in the Software without restriction, including without limitation the
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:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 */
24
51
52
53struct lws_cache_ttl_lru;
54
74LWS_VISIBLE LWS_EXTERN int /* only valid until return to event loop */
75lws_cache_write_through(struct lws_cache_ttl_lru *cache,
76 const char *specific_key, const uint8_t *source,
77 size_t size, lws_usec_t expiry, void **ppay);
78
79typedef struct lws_cache_match {
82 /* earliest expiry amongst results */
87 size_t tag_size;
88
89 /* tag name + NUL is overcommitted */
91
132lws_cache_lookup(struct lws_cache_ttl_lru *cache, const char *wildcard_key,
133 const void **pdata, size_t *psize);
134
153lws_cache_item_get(struct lws_cache_ttl_lru *cache, const char *specific_key,
154 const void **pdata, size_t *psize);
155
169lws_cache_item_remove(struct lws_cache_ttl_lru *cache, const char *wildcard_key);
170
178LWS_VISIBLE LWS_EXTERN uint64_t
179lws_cache_footprint(struct lws_cache_ttl_lru *cache);
180
189lws_cache_debug_dump(struct lws_cache_ttl_lru *cache);
190
191typedef struct lws_cache_results {
192 const uint8_t *ptr; /* set before using walk api */
193 size_t size; /* set before using walk api */
194
196 size_t tag_len;
197 const uint8_t *tag;
199
218
219typedef void (*lws_cache_item_destroy_cb)(void *item, size_t size);
221 struct lws_context *cx;
223 const char *name;
227 struct lws_cache_ttl_lru *parent;
229 const struct lws_cache_ops *ops;
232
233 union {
234 struct {
235 const char *filepath;
237 } nscookiejar;
238 } u;
239
240
244 size_t max_items;
249 int tsi;
251};
252
254 struct lws_cache_ttl_lru *
255 (*create)(const struct lws_cache_creation_info *info);
257
258 void
259 (*destroy)(struct lws_cache_ttl_lru **_cache);
262
263 int
264 (*expunge)(struct lws_cache_ttl_lru *cache);
267
268 int
269 (*write)(struct lws_cache_ttl_lru *cache, const char *specific_key,
270 const uint8_t *source, size_t size, lws_usec_t expiry,
271 void **ppvoid);
273 int
274 (*tag_match)(struct lws_cache_ttl_lru *cache, const char *wc,
275 const char *tag, char lookup_rules);
280 int
281 (*lookup)(struct lws_cache_ttl_lru *cache, const char *wildcard_key,
282 lws_dll2_owner_t *results_owner);
285 int
286 (*invalidate)(struct lws_cache_ttl_lru *cache, const char *wildcard_key);
288
289 int
290 (*get)(struct lws_cache_ttl_lru *cache, const char *specific_key,
291 const void **pdata, size_t *psize);
294
295 void
296 (*debug_dump)(struct lws_cache_ttl_lru *cache);
298};
299
317LWS_VISIBLE LWS_EXTERN struct lws_cache_ttl_lru *
319
329lws_cache_destroy(struct lws_cache_ttl_lru **cache);
330
342lws_cache_expunge(struct lws_cache_ttl_lru *cache);
343
344LWS_VISIBLE extern const struct lws_cache_ops lws_cache_ops_heap,
346
348
struct lws_dll2 lws_dll2_t
struct lws_dll2_owner lws_dll2_owner_t
lws_usec_t expiry
struct lws_context * cx
int(* get)(struct lws_cache_ttl_lru *cache, const char *specific_key, const void **pdata, size_t *psize)
union lws_cache_creation_info::@024221170201115224051375337135263102206361077057 u
struct lws_cache_ttl_lru * parent
void(* destroy)(struct lws_cache_ttl_lru **_cache)
int(* lookup)(struct lws_cache_ttl_lru *cache, const char *wildcard_key, lws_dll2_owner_t *results_owner)
const uint8_t * ptr
void(* debug_dump)(struct lws_cache_ttl_lru *cache)
const struct lws_cache_ops * ops
lws_dll2_t list
int(* write)(struct lws_cache_ttl_lru *cache, const char *specific_key, const uint8_t *source, size_t size, lws_usec_t expiry, void **ppvoid)
int(* invalidate)(struct lws_cache_ttl_lru *cache, const char *wildcard_key)
const uint8_t * tag
int(* tag_match)(struct lws_cache_ttl_lru *cache, const char *wc, const char *tag, char lookup_rules)
lws_cache_item_destroy_cb cb
int(* expunge)(struct lws_cache_ttl_lru *cache)
LWS_VISIBLE LWS_EXTERN void lws_cache_debug_dump(struct lws_cache_ttl_lru *cache)
LWS_VISIBLE LWS_EXTERN int lws_cache_item_get(struct lws_cache_ttl_lru *cache, const char *specific_key, const void **pdata, size_t *psize)
LWS_VISIBLE LWS_EXTERN struct lws_cache_ttl_lru * lws_cache_create(const struct lws_cache_creation_info *info)
struct lws_cache_match lws_cache_match_t
LWS_VISIBLE LWS_EXTERN int lws_cache_lookup(struct lws_cache_ttl_lru *cache, const char *wildcard_key, const void **pdata, size_t *psize)
LWS_VISIBLE LWS_EXTERN int lws_cache_expunge(struct lws_cache_ttl_lru *cache)
LWS_VISIBLE LWS_EXTERN uint64_t lws_cache_footprint(struct lws_cache_ttl_lru *cache)
LWS_VISIBLE LWS_EXTERN int lws_cache_write_through(struct lws_cache_ttl_lru *cache, const char *specific_key, const uint8_t *source, size_t size, lws_usec_t expiry, void **ppay)
void(* lws_cache_item_destroy_cb)(void *item, size_t size)
LWS_VISIBLE LWS_EXTERN int lws_cache_results_walk(lws_cache_results_t *walk_ctx)
LWS_VISIBLE LWS_EXTERN int lws_cache_item_remove(struct lws_cache_ttl_lru *cache, const char *wildcard_key)
LWS_VISIBLE LWS_EXTERN void lws_cache_destroy(struct lws_cache_ttl_lru **cache)
LWS_VISIBLE const struct lws_cache_ops lws_cache_ops_heap lws_cache_ops_nscookiejar
struct lws_cache_results lws_cache_results_t
#define LWS_EXTERN
int64_t lws_usec_t
unsigned char uint8_t
#define LWS_VISIBLE