Caching Strategies Knowledge logo

Caching Strategies Knowledge

Community
dykyi-roman
caching-strategies-knowledge

Caching Strategies knowledge base. Provides caching patterns (Cache-Aside, Read-Through, Write-Through, Write-Behind), invalidation approaches, multi-level caching, and Redis data structures for caching audits and generation.

Overview

Publisherdykyi-roman
Repositoryawesome-claude-code
Skill namecaching-strategies-knowledge
Stars
98
Forks
25
Bundled files
3
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by dykyi-roman on GitHub. Read the source before you install it.

Installation

Install the Caching Strategies Knowledge AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dykyi-roman/awesome-claude-code.git /tmp/awesome-claude-code
mkdir -p .claude/skills
cp -r /tmp/awesome-claude-code/skills/caching-strategies-knowledge .claude/skills/caching-strategies-knowledge
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Caching Strategies Knowledge in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Caching Strategies Knowledge on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Caching Strategies Knowledge is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Caching Strategies Knowledge Base

Quick reference for caching patterns, invalidation strategies, and Redis implementation guidelines. Focuses on caching theory and Redis patterns — for Cache-Aside code generation, see create-cache-aside.

Caching Strategies

StrategyHow It WorksConsistencyPerformanceUse Case
Cache-AsideApp reads cache first, fetches from DB on miss, writes to cacheEventualRead-heavyGeneral purpose, most common
Read-ThroughCache itself fetches from DB on missEventualRead-heavyTransparent caching layer
Write-ThroughApp writes to cache and DB synchronouslyStrongWrite-heavy (slower writes)Consistency-critical data
Write-BehindApp writes to cache, cache writes to DB asynchronouslyEventualWrite-heavy (fast writes)High write throughput
Write-AroundApp writes directly to DB, cache populated on readEventualInfrequent-read dataWrite-once, read-later

Strategy Flow Diagrams

Cache-Aside (Lazy Loading):
  Read:  App → Cache (hit?) → yes → return
                             → no  → DB → write to Cache → return
  Write: App → DB → invalidate Cache

Read-Through:
  Read:  App → Cache (hit?) → yes → return
                             → no  → Cache fetches from DB → return
  Write: App → DB → invalidate Cache

Write-Through:
  Read:  App → Cache (hit?) → yes → return
                             → no  → DB → return
  Write: App → Cache → Cache writes to DB (sync)

Write-Behind (Write-Back):
  Read:  App → Cache (hit?) → yes → return
                             → no  → DB → return
  Write: App → Cache → Cache writes to DB (async, batched)

Cache Invalidation Approaches

ApproachDescriptionConsistencyComplexity
TTL (Time-To-Live)Cache expires after fixed durationEventual (stale window)Low
Event-DrivenInvalidate on domain eventNear real-timeMedium
Versioned KeysInclude version in cache keyImmediate (new key)Medium
Tag-BasedGroup related keys by tag, purge by tagImmediateHigh
Write-ThroughUpdate cache on writeImmediateMedium
ManualExplicit invalidation in codeDepends on disciplineLow

TTL Selection Guide

Data TypeTTLReasoning
Static config1-24 hoursRarely changes
User profile5-15 minutesModerate change frequency
Session data30 minutesLinked to session timeout
Product catalog1-5 minutesModerate updates
Search results30-60 secondsFrequent updates
Real-time data5-15 secondsHigh change frequency
Counters/statsNo TTL (event-driven)Update on write

Multi-Level Caching

┌─────────────────────────────────────────────────┐
│                 MULTI-LEVEL CACHE                 │
│                                                   │
│   Request → L1 (In-Process)  hit → return         │
│                              miss ↓               │
│            L2 (Redis/Memcached) hit → populate L1  │
│                              miss ↓               │
│            L3 (CDN/HTTP Cache) hit → populate L2   │
│                              miss ↓               │
│            Database → populate L2 → populate L1    │
└─────────────────────────────────────────────────┘
LevelStorageLatencyCapacityScope
L1In-process (APCu, static)< 1μsSmall (MB)Per-process
L2Distributed (Redis)1-5msLarge (GB)Shared
L3CDN / HTTP Cache5-50msVery largeGlobal
OriginDatabase10-100msUnlimitedSource of truth

Redis Data Structures for Caching

StructureWhen to UseExample
StringSimple key-value, serialized objectsUser session, JSON blob
HashObject with fields, partial readsUser profile (name, email, role)
Sorted SetRanked data, leaderboards, time-seriesTop products, recent activity
ListQueues, recent items, feedsRecent notifications
SetUnique collections, tagsUser permissions, online users
HyperLogLogCardinality estimationUnique visitors count

Strategy Selection by Workload

WorkloadStrategyWhy
Read-heavy, tolerance for staleCache-Aside + TTLSimple, effective
Read-heavy, consistency neededCache-Aside + event invalidationFresh data
Write-heavy, read-after-writeWrite-ThroughImmediate consistency
Write-heavy, async OKWrite-BehindBest write performance
Mixed, complex invalidationTag-based + event-drivenGranular control
API responsesHTTP Cache (CDN) + L2Reduce server load

Detection Patterns

bash
# Cache usage
Grep: "Cache|Redis|Memcached|APCu|apc_" --glob "**/*.php"
Grep: "CacheInterface|CacheItemPoolInterface|SimpleCacheInterface" --glob "**/*.php"

# Cache-Aside pattern
Grep: "->get\(.*\).*->set\(" --glob "**/*.php"
Grep: "cache->has|cache->get|cache->set" --glob "**/*.php"

# TTL configuration
Grep: "ttl|expire|setex|SETEX|TTL" --glob "**/*.php"
Grep: "CACHE_TTL|CACHE_LIFETIME" --glob "**/.env*"

# Cache invalidation
Grep: "->delete\(|->invalidate\(|->clear\(|->flush\(" --glob "**/*.php"
Grep: "invalidateTag|invalidateTags|clearByTag" --glob "**/*.php"

# Redis patterns
Grep: "Predis|PhpRedis|Redis::|new Redis" --glob "**/*.php"
Grep: "REDIS_HOST|REDIS_URL" --glob "**/.env*"

# Multi-level caching
Grep: "ChainCache|StackedCache|MultiLevelCache" --glob "**/*.php"
Grep: "apcu_fetch|apcu_store" --glob "**/*.php"

Advanced Patterns

Cache Stampede Prevention

MethodHow It WorksComplexityBest For
Locking (Mutex)One process recomputes, others waitMediumMost cases
Probabilistic Early Expiry (XFetch)Recompute before TTL with probabilityMediumHigh concurrency
Stale-While-RevalidateServe stale, refresh asyncMediumLatency-critical
External refreshCron/worker refreshes before expiryLowPredictable access

Distributed Cache Coherence

StrategyConsistencyLatencyComplexity
TTL onlyEventual (stale window)NoneLow
Pub/Sub invalidationNear-real-time~1-5msMedium
Write-through all nodesStrongHighHigh
Version-based (ETag)Strong (on read)Per-read checkMedium

Write-Back vs Write-Through

AspectWrite-ThroughWrite-Back
Write latencyHigher (sync)Lower (cache only)
Data safetySafeRisk of loss
ConsistencyStrongEventual
DB loadPer-writeBatched
Use caseFinancial, ordersAnalytics, counters

References

For detailed information, load these reference files:

  • references/strategies.md — Detailed strategy analysis, cache warming, stampede prevention, distributed consistency
  • references/redis-patterns.md — Eviction policies, data structure guide, cluster/sentinel, Lua scripting, PHP patterns
  • references/advanced-patterns.md — Cache stampede prevention (locking, XFetch, stale-while-revalidate), cache warming strategies, write-back vs write-through comparison, distributed cache coherence, key design patterns

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Caching Strategies Knowledge AI skill do?

Caching Strategies knowledge base. Provides caching patterns (Cache-Aside, Read-Through, Write-Through, Write-Behind), invalidation approaches, multi-level caching, and Redis data structures for caching audits and generation.

Why use Caching Strategies Knowledge on TypingMind?

Because you install it once and use it with any model. Caching Strategies Knowledge is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Caching Strategies Knowledge in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/dykyi-roman/awesome-claude-code/tree/master/skills/caching-strategies-knowledge. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Caching Strategies Knowledge?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Caching Strategies Knowledge?

As many as you like. As long as a model supports skills, you can use Caching Strategies Knowledge with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Caching Strategies Knowledge AI skill free?

Yes. It is published on GitHub by dykyi-roman under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇