17#ifndef PROTOCORE_EDGE_CACHE_H
18#define PROTOCORE_EDGE_CACHE_H
22#if PROTOCORE_ENABLE_EDGE_CACHE
30#define PROTOCORE_EDGE_LRU_NONE 0xFFFFu
33typedef const char *(*EdgeHdrLookup)(
void *ctx,
const char *name);
35typedef struct EdgeEntry
48 int64_t expires_epoch;
53 uint32_t last_used_ms;
60 uint8_t body[PROTOCORE_EDGE_BODY_MAX];
64typedef struct EdgeCacheStats
68 uint32_t revalidations_304;
69 uint32_t replaces_200;
77 uint64_t bytes_stored;
87typedef void (*EdgeEvictFn)(
void *ctx,
const EdgeEntry *victim);
92 EdgeEntry entries[PROTOCORE_EDGE_CACHE_SLOTS];
103struct protocore_cache_control;
113} EdgeCacheHeaderValueArgs;
120} EdgeCacheParseHttpDateArgs;
125 const struct protocore_cache_control *cc;
128 int64_t expires_epoch;
129} EdgeCacheFreshnessLifetimeArgs;
135 int64_t last_modified_epoch;
136} EdgeCacheHeuristicLifetimeArgs;
143 int64_t response_time_epoch;
144} EdgeCacheInitialAgeArgs;
152} EdgeCacheCurrentAgeArgs;
159} EdgeCacheIsFreshAtArgs;
171} EdgeCacheKeyCanonArgs;
176 uint8_t *digest_work;
180} EdgeCacheKeyDigestArgs;
185 const char *vary_header;
186 EdgeHdrLookup lookup;
190} EdgeCacheVarySerializeArgs;
196} EdgeCacheStoreInitArgs;
203 const char *vary_key;
204} EdgeCacheStoreAllocArgs;
211 const char *vary_key;
213} EdgeCacheStoreLookupArgs;
220 EdgeHdrLookup lookup;
223} EdgeCacheStoreFindArgs;
229 const struct protocore_cache_control *cc;
232 int64_t expires_epoch;
233 int64_t last_modified_epoch;
235 int64_t response_time_epoch;
237} EdgeCacheEntrySetFreshnessArgs;
243} EdgeCacheEntryHasValidatorArgs;
250} EdgeCacheEntryFreshArgs;
257} EdgeCacheStoreSweepArgs;
264} EdgeCacheStorePurgeArgs;
271} EdgeCacheStorePurgePrefixArgs;
278} EdgeCacheStoreFreeEntryArgs;
285 const struct protocore_cache_control *cc;
286 const char *vary_header;
288} EdgeCacheIsStoreableArgs;
296} EdgeCacheBuildConditionalArgs;
302 const char *new_hdrs;
304 int64_t response_time_epoch;
306} EdgeCacheApply304Args;
383 EdgeCacheHeaderValueArgs header_value_args;
384 EdgeCacheParseHttpDateArgs parse_http_date_args;
385 EdgeCacheFreshnessLifetimeArgs freshness_lifetime_args;
386 EdgeCacheHeuristicLifetimeArgs heuristic_lifetime_args;
387 EdgeCacheInitialAgeArgs initial_age_args;
388 EdgeCacheCurrentAgeArgs current_age_args;
389 EdgeCacheIsFreshAtArgs is_fresh_at_args;
390 EdgeCacheKeyCanonArgs key_canon_args;
391 EdgeCacheKeyDigestArgs key_digest_args;
392 EdgeCacheVarySerializeArgs vary_serialize_args;
393 EdgeCacheStoreInitArgs store_init_args;
394 EdgeCacheStoreAllocArgs store_alloc_args;
395 EdgeCacheStoreLookupArgs store_lookup_args;
396 EdgeCacheStoreFindArgs store_find_args;
397 EdgeCacheEntrySetFreshnessArgs entry_set_freshness_args;
398 EdgeCacheEntryHasValidatorArgs entry_has_validator_args;
399 EdgeCacheEntryFreshArgs entry_fresh_args;
400 EdgeCacheStoreSweepArgs store_sweep_args;
401 EdgeCacheStorePurgeArgs store_purge_args;
402 EdgeCacheStorePurgePrefixArgs store_purge_prefix_args;
403 EdgeCacheStoreFreeEntryArgs store_free_entry_args;
404 EdgeCacheIsStoreableArgs is_storeable_args;
405 EdgeCacheBuildConditionalArgs build_conditional_args;
406 EdgeCacheApply304Args apply_304_args;
416extern EdgeCacheVars EdgeCacheV;
421 void (*
const header_value)(uint8_t *work);
422 void (*
const parse_http_date)(uint8_t *work);
423 void (*
const freshness_lifetime)(uint8_t *work);
424 void (*
const heuristic_lifetime)(uint8_t *work);
425 void (*
const initial_age)(uint8_t *work);
426 void (*
const current_age)(uint8_t *work);
427 void (*
const is_fresh_at)(uint8_t *work);
428 void (*
const key_canon)(uint8_t *work);
429 void (*
const key_digest)(uint8_t *work);
430 void (*
const vary_serialize)(uint8_t *work);
431 void (*
const store_init)(uint8_t *work);
432 void (*
const store_alloc)(uint8_t *work);
433 void (*
const store_lookup)(uint8_t *work);
434 void (*
const store_find)(uint8_t *work);
435 void (*
const entry_set_freshness)(uint8_t *work);
436 void (*
const entry_has_validator)(uint8_t *work);
437 void (*
const entry_fresh)(uint8_t *work);
438 void (*
const store_sweep)(uint8_t *work);
439 void (*
const store_purge)(uint8_t *work);
440 void (*
const store_purge_prefix)(uint8_t *work);
441 void (*
const store_free_entry)(uint8_t *work);
442 void (*
const is_storeable)(uint8_t *work);
443 void (*
const build_conditional)(uint8_t *work);
444 void (*
const apply_304)(uint8_t *work);
449void protocore_edge_cache_header_value(uint8_t *work);
450void protocore_edge_cache_parse_http_date(uint8_t *work);
451void protocore_edge_cache_freshness_lifetime(uint8_t *work);
452void protocore_edge_cache_heuristic_lifetime(uint8_t *work);
453void protocore_edge_cache_initial_age(uint8_t *work);
454void protocore_edge_cache_current_age(uint8_t *work);
455void protocore_edge_cache_is_fresh_at(uint8_t *work);
456void protocore_edge_cache_key_canon(uint8_t *work);
457void protocore_edge_cache_key_digest(uint8_t *work);
458void protocore_edge_cache_vary_serialize(uint8_t *work);
459void protocore_edge_cache_store_init(uint8_t *work);
460void protocore_edge_cache_store_alloc(uint8_t *work);
461void protocore_edge_cache_store_lookup(uint8_t *work);
462void protocore_edge_cache_store_find(uint8_t *work);
463void protocore_edge_cache_entry_set_freshness(uint8_t *work);
464void protocore_edge_cache_entry_has_validator(uint8_t *work);
465void protocore_edge_cache_entry_fresh(uint8_t *work);
466void protocore_edge_cache_store_sweep(uint8_t *work);
467void protocore_edge_cache_store_purge(uint8_t *work);
468void protocore_edge_cache_store_purge_prefix(uint8_t *work);
469void protocore_edge_cache_store_free_entry(uint8_t *work);
470void protocore_edge_cache_is_storeable(uint8_t *work);
471void protocore_edge_cache_build_conditional(uint8_t *work);
472void protocore_edge_cache_apply_304(uint8_t *work);
478static const EdgeCacheNs EdgeCache __attribute__((unused)) = {
479 .header_value = protocore_edge_cache_header_value,
480 .parse_http_date = protocore_edge_cache_parse_http_date,
481 .freshness_lifetime = protocore_edge_cache_freshness_lifetime,
482 .heuristic_lifetime = protocore_edge_cache_heuristic_lifetime,
483 .initial_age = protocore_edge_cache_initial_age,
484 .current_age = protocore_edge_cache_current_age,
485 .is_fresh_at = protocore_edge_cache_is_fresh_at,
486 .key_canon = protocore_edge_cache_key_canon,
487 .key_digest = protocore_edge_cache_key_digest,
488 .vary_serialize = protocore_edge_cache_vary_serialize,
489 .store_init = protocore_edge_cache_store_init,
490 .store_alloc = protocore_edge_cache_store_alloc,
491 .store_lookup = protocore_edge_cache_store_lookup,
492 .store_find = protocore_edge_cache_store_find,
493 .entry_set_freshness = protocore_edge_cache_entry_set_freshness,
494 .entry_has_validator = protocore_edge_cache_entry_has_validator,
495 .entry_fresh = protocore_edge_cache_entry_fresh,
496 .store_sweep = protocore_edge_cache_store_sweep,
497 .store_purge = protocore_edge_cache_store_purge,
498 .store_purge_prefix = protocore_edge_cache_store_purge_prefix,
499 .store_free_entry = protocore_edge_cache_store_free_entry,
500 .is_storeable = protocore_edge_cache_is_storeable,
501 .build_conditional = protocore_edge_cache_build_conditional,
502 .apply_304 = protocore_edge_cache_apply_304,
#define PROTOCORE_EDGE_ETAG_MAX
Stored validator (ETag, quotes included).
#define PROTOCORE_EDGE_CENC_MAX
Stored Content-Encoding to replay (e.g. gzip).
#define PROTOCORE_EDGE_LASTMOD_MAX
Stored Last-Modified (RFC 1123 date).
#define PROTOCORE_EDGE_KEY_MAX
#define PROTOCORE_EDGE_VARY_MAX
#define PROTOCORE_EDGE_CTYPE_MAX
Stored Content-Type to replay.
#define PROTOCORE_SHA256_BORROW
Worst-case bytes each module borrows from the secure pool in a single call.
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS