Skip to content

Instantly share code, notes, and snippets.

@hamishforbes
Created November 28, 2018 09:36
Show Gist options
  • Save hamishforbes/d15faa8089f7d1098bce57f31ddc23cd to your computer and use it in GitHub Desktop.
Save hamishforbes/d15faa8089f7d1098bce57f31ddc23cd to your computer and use it in GitHub Desktop.
Ledge Cache Tags notes
Cache Tags
TODO
housekeeping gracefulness
housekeeping tests
case tests
multi tag tests
unit tests
Tags
tag_id = <http_host>:<tagname>
set of full keys - no ttl
ledge:cache_tag:<http_host>:<tagname>
ledge:cache:<key_spec>#<vary_key>::main
on refresh
determine tag sets from cached response
remove from all tag sets
on save
always sadd - touches tag key
Evicted entries might exist in an old tag set, but house keeping should catch that
and the purge job checks first
Response header: 'Cache-Tags: tag1, tag2'
Housekeeping
Set of all tags in system cache_tag sets to keep track - no ttl
recurring background job to clean up
- Get list of all tag sets
- iterate
- if tag set missing, remove from global set
- iterate over main keys
- if main key missing remove from tag set
- if cached response no logner matches, remove from tag set
sscan sets?
sleep for gracefulness?
Purge cache tag
- Look up tag set
- iterate
- headless purge -- see wildcard purge job
- remove from tag set IF cached response matches current tag set
purge delete - removes from all tag set
purge invalidate - retain for revalidation
purge revalidate - retain for revalidation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment