Check Caching Strategy logo

Check Caching Strategy

Community
dykyi-roman
check-caching-strategy

Analyzes PHP code for caching opportunities and issues. Detects missing cache, cache invalidation problems, over-caching, repeated expensive operations.

Overview

Publisherdykyi-roman
Repositoryawesome-claude-code
Skill namecheck-caching-strategy
Stars
98
Forks
25
Bundled files
Instructions only
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.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

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

Installation

Install the Check Caching Strategy 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/check-caching-strategy .claude/skills/check-caching-strategy
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Check Caching Strategy 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 Check Caching Strategy 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 Check Caching Strategy 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 Strategy Analysis

Analyze PHP code for caching opportunities and issues.

Detection Patterns

1. Missing Cache Opportunities

php
// CACHEABLE: Repeated expensive computation
public function getExchangeRate(string $currency): float
{
    return $this->api->fetchRate($currency); // API call each time
}

// CACHEABLE: Repeated database query
public function getSettings(): array
{
    return $this->repository->findAll(); // Same query repeatedly
}

// CACHEABLE: Configuration that rarely changes
public function getFeatureFlags(): array
{
    return $this->configLoader->load(); // File read each request
}

2. Cache Invalidation Issues

php
// STALE DATA: No invalidation
$cache->set('user_' . $id, $user, 3600);
// Later: user updated but cache not cleared

// STALE DATA: Time-based only
$cache->set('products', $products, 86400);
// Products change but cache lives for 24h

// RACE CONDITION: Invalidate before update
$this->cache->delete('user_' . $id);
$this->repository->update($user);
// Another request may cache old data between these lines

3. Over-Caching

php
// OVER-CACHED: User-specific data with long TTL
$cache->set('user_dashboard_' . $userId, $data, 86400);
// User dashboard may need fresh data

// OVER-CACHED: Rapidly changing data
$cache->set('stock_count_' . $productId, $count, 3600);
// Stock changes frequently

// OVER-CACHED: Huge cache entries
$cache->set('all_products', $allProducts); // 10MB cache entry

4. Cache Stampede

php
// STAMPEDE: Many requests rebuild cache simultaneously
public function getData(): array
{
    $data = $this->cache->get('key');
    if (!$data) {
        $data = $this->expensiveOperation(); // All concurrent requests hit this
        $this->cache->set('key', $data, 3600);
    }
    return $data;
}

// FIXED: Lock during rebuild
public function getData(): array
{
    $data = $this->cache->get('key');
    if (!$data) {
        $lock = $this->lockFactory->createLock('key_rebuild');
        if ($lock->acquire()) {
            $data = $this->expensiveOperation();
            $this->cache->set('key', $data, 3600);
            $lock->release();
        } else {
            $data = $this->cache->get('key'); // Wait for other process
        }
    }
    return $data;
}

5. Wrong Cache Key

php
// BAD: Missing important parameters
$cache->get('user_data'); // Same for all users?

// BAD: Too specific
$cache->get('user_' . $id . '_' . $requestId); // Never hits

// BAD: Collision risk
$cache->get(md5($query)); // Different queries may collide

// GOOD: Meaningful, unique key
$cache->get(sprintf('user:%d:profile:v1', $userId));

6. Cache Storage Issues

php
// PROBLEM: Storing large objects
$cache->set('report', $largeReport); // 50MB serialized

// PROBLEM: Storing non-serializable
$cache->set('connection', $pdoConnection); // Can't serialize

// PROBLEM: Storing closures
$cache->set('callback', function() { }); // Fails

7. TTL Issues

php
// TOO SHORT: Cache overhead exceeds benefit
$cache->set('data', $data, 1); // 1 second TTL

// TOO LONG: Stale data risk
$cache->set('exchange_rates', $rates, 604800); // 1 week

// NO TTL: Memory leak risk
$cache->set('data', $data); // Never expires

// FIXED: Appropriate TTL
$cache->set('exchange_rates', $rates, 300); // 5 minutes

8. Cache Warming

php
// COLD START: First request is slow
// No warming strategy, first user waits

// BETTER: Warm cache on deploy/schedule
public function warmCache(): void
{
    $this->cache->set('config', $this->loadConfig());
    $this->cache->set('categories', $this->loadCategories());
}

Grep Patterns

bash
# API calls without cache
Grep: "->request\(|->get\(|->fetch\(" --glob "**/*.php"

# Repository calls that could be cached
Grep: "Repository->find|Repository->get" --glob "**/*.php"

# Cache operations
Grep: "->cache->|Cache::|redis->|memcache" --glob "**/*.php"

# Missing TTL
Grep: "->set\([^,]+,[^,]+\)\s*;" --glob "**/*.php"

Caching Patterns

Read-Through Cache

php
public function get(string $key, callable $loader, int $ttl = 3600): mixed
{
    $value = $this->cache->get($key);
    if ($value === null) {
        $value = $loader();
        $this->cache->set($key, $value, $ttl);
    }
    return $value;
}

Write-Through Cache

php
public function update(Entity $entity): void
{
    $this->repository->save($entity);
    $this->cache->set('entity:' . $entity->getId(), $entity);
}

Cache-Aside with Locking

php
public function getWithLock(string $key, callable $loader): mixed
{
    $value = $this->cache->get($key);
    if ($value !== null) {
        return $value;
    }

    $lock = $this->lockFactory->createLock($key);
    if ($lock->acquire()) {
        try {
            $value = $loader();
            $this->cache->set($key, $value);
        } finally {
            $lock->release();
        }
    } else {
        usleep(100000);
        return $this->getWithLock($key, $loader);
    }
    return $value;
}

Severity Classification

PatternSeverity
Cache stampede risk🔴 Critical
Missing invalidation🟠 Major
Missing cache for hot path🟠 Major
Wrong cache key🟠 Major
Overly long TTL🟡 Minor
Over-caching user data🟡 Minor

Output Format

markdown
### Caching Issue: [Description]

**Severity:** 🔴/🟠/🟡
**Location:** `file.php:line`
**Type:** [Missing Cache|Invalidation|Stampede|...]

**Issue:**
[Description of the caching problem]

**Code:**
```php
// Current code

Fix:

php
// With proper caching

Expected Improvement: Response time: 500ms → 5ms (on cache hit) Database load: 1000 QPS → 100 QPS


## When This Is Acceptable

- **Premature caching** — Adding cache before proving a performance bottleneck exists creates complexity without benefit
- **Frequently changing data** — Data that changes on every request (e.g., real-time prices) shouldn't be cached
- **Development environment** — Missing cache in dev/test environments is intentional

### False Positive Indicators
- Code is in early development stage without performance profiling
- Data has TTL < 1 second or changes per-request
- Cache is disabled by environment configuration (dev/test)

Frequently asked questions

What does the Check Caching Strategy AI skill do?

Analyzes PHP code for caching opportunities and issues. Detects missing cache, cache invalidation problems, over-caching, repeated expensive operations.

Why use Check Caching Strategy on TypingMind?

Because you install it once and use it with any model. Check Caching Strategy 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 Check Caching Strategy in TypingMind?

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

Which AI models can use Check Caching Strategy?

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 Check Caching Strategy?

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

Is the Check Caching Strategy 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 👇