aiocache

A guide for using aiocache, a Python library for asynchronous caching, in a project. It covers in-memory caching, optional Redis storage, expiration times, and a fallback that disables caching safely.

In plain words
What is it for?
Read, write, delete, and clear cached values; configure memory or Redis-backed caches; set expiration times; and understand the NoOpCache fallback.
Why use it?
It keeps cache behavior consistent and provides a fallback when caching is turned off or Redis is unavailable.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/tedivm/robs_awesome_python_template/aiocache
Any agent
npx skills add tedivm/robs_awesome_python_template --skill aiocache
Clone the repo
git clone --depth 1 https://github.com/tedivm/robs_awesome_python_template

Made for: Claude Code, Codex.

Per session 47 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,933 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00047 $0.01933
Opus 5 $0.00023 $0.00966
Sonnet 5 $0.00009 $0.00387
Haiku 4.5 $0.00005 $0.00193

Measured 3d ago against content hash e46507e20206, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

aiocache scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

{{cookiecutter.__package_slug}}/.agents/skills/aiocache/SKILL.md · 225 lines

How it starts

The opening of the file, as written. The whole thing — 225 lines — stays where its author put it; the contents beside it link to each section on GitHub.

aiocache Caching

context7: If the context7 tools are available, resolve and load the full aiocache documentation before making changes:

context7_resolve-library-id: "aiocache"
context7_query-docs: /aio-libs/aiocache

The caching layer is defined in {{cookiecutter.__package_slug}}/services/cache.py. It provides helper functions and a NoOpCache fallback for when caching is disabled.


Cache Aliases

Three cache backends are configured by configure_caches():

Alias Backend Default TTL
memory Always in-memory cache_default_ttl (300s)
persistent Redis if configured, else memory cache_persistent_ttl (3600s)
default Same as memory cache_persistent_ttl (3600s)*

* Note: set_cached() applies cache_default_ttl only when alias == "memory", so default falls through to cache_persistent_ttl.


Using the Helpers

from {{cookiecutter.__package_slug}}.services.cache import get_cached, set_cached, delete_cached, clear_cache

# Get (returns None on miss)
value = await get_cached("user:123")

# Set with default TTL
await set_cached("user:123", user_data)

# Set with custom TTL
await set_cached("user:123", user_data, ttl=600, alias="persistent")

# Delete
await delete_cached("user:123", alias="persistent")

# Clear entire cache
await clear_cache(alias="persistent")

Direct Cache Access

For operations not covered by the helpers:

from {{cookiecutter.__package_slug}}.services.cache import get_cache

cache = get_cache("memory")
exists = await cache.exists("key")

Cache Decorator

Use @cached to automatically cache function return values. The decorator takes a cache instance (not an alias string) as its first argument. Retrieve the instance with get_cache():

from aiocache import cached
from {{cookiecutter.__package_slug}}.services.cache import get_cache

@cached(get_cache("memory"), ttl=300, key_builder=lambda f, *args, **kwargs: f"user:{args[0]}")
async def get_user(user_id: int) -> dict[str, str] | None:
    # Expensive DB call — cached for 300s
    return await fetch_user_from_db(user_id)

Read the full file on GitHub · 225 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 225 lines · 47 tokens per session scan A e46507e20206

Subscribe to this mod's changes

aiocache is a skill published in the GitHub repository tedivm/robs_awesome_python_template (309 stars, last pushed 3mo ago), licensed MIT. It adds 47 tokens to every session and 1,933 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

background-tasks

Async task execution authority — Celery workers and beat scheduler, APScheduler in-process cron, bare Redis LPUSH/BRPOP queues, dead-letter queues, idempotency patterns, task monitoring, and Docker Compose worker definitions for Python pipelines.

LuuOW/meridian-mcp · 51 tokens

mysql reporter

生成 MySQL 查询报表并生成可视化图表。当用户需要查询 MySQL 数据库并以报表形式展示结果时使用此技能,包括:统计销售数据、分析用户行为、生成业务报表、查询业务指标等。.

xerrors/Yuxi · 55 tokens

alembic-migration

Create, review, and apply database schema changes with Alembic. Use whenever a SQLAlchemy model is added or changed, a column/index/constraint needs to change, or a data backfill is required — anything that alters the PostgreSQL schema.

vstorm-co/full-stack-ai-agent-template · 56 tokens

后端编码

后端技术栈编码技能(规范+流程)。含 API 设计、数据库规范、错误处理、日志规范、API 端点测试要求。用于后端/全栈任务的编码阶段。.

jianchen08/Agent-os-open · 49 tokens

database-management

Standards for SQLAlchemy async models, PostgreSQL indexing, UTC datetimes, and Alembic migrations.

aps08/fullstack-clean-architecture · 25 tokens

azure-resource-manager-redis-dotnet

Azure Resource Manager SDK for Redis in .NET. Use for MANAGEMENT PLANE operations: creating/managing Azure Cache for Redis instances, firewall rules, access keys, patch schedules, linked servers (geo-replication), and private endpoints via Azure Resource Manager. NOT for data plane operations (get/set keys, pub/sub) …

microsoft/skills · 114 tokens