data-persistence-caching

Design database schemas, indexes, and Redis cache-aside invalidation strategies.

1|Updated Jun 29, 2026
One-click install
npx skills add https://github.com/coreyone/software-maestro --skill data-persistence-caching-coreyone
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: data-persistence-caching
Source: https://github.com/coreyone/software-maestro/tree/main/data-and-api/data-persistence-caching
Command: npx skills add https://github.com/coreyone/software-maestro --skill data-persistence-caching-coreyone

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Designing reliable data persistence is hard: poorly indexed queries cause slow sequential scans, and misconfigured caches lead to stale data, stampedes, and out-of-memory crashes. This Skill guides the design of database schemas, indexing strategies, and cache invalidation flows that protect data integrity while optimizing retrieval. ## Core Features & Use Cases - Schema & Index Design: Outline PostgreSQL/SQLite schemas, composite B-tree indexes, and transaction boundaries with ACID guarantees. - Caching Topology: Implement cache-aside, write-through, and write-behind patterns with LRU eviction, TTLs, and stampede mitigation via mutex locks or probabilistic early expiration. - Mobile & Sync Persistence: Apply CoreData/SwiftData background concurrency rules, batch mutations, and offline sync with CRDTs or ETag conflict handling. - Use Case: When building a high-read user profile service, use this Skill to define a composite index on queried columns and a Redis cache-aside flow that populates on miss and invalidates keys on writes. ## Quick Start Ask the agent to design a PostgreSQL schema with composite indexes and a Redis cache-aside invalidation strategy for your high-read query service.

Frequently Asked Questions about data-persistence-caching

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design a Redis cache-aside invalidation strategy?▼

Cache-aside works by querying Redis first, and on a miss, reading from the database and populating the cache with a TTL. On writes, update the database and immediately delete the corresponding cache key to prevent stale reads.

How to create composite indexes in PostgreSQL for slow queries?▼

Create composite B-tree indexes with columns ordered as equality, sorting, then range, such as (status, created_at). This eliminates sequential scans for filtered and ordered queries, but avoid indexing every column since it degrades write performance.

What is the difference between cache-aside, write-through, and write-behind caching?▼

Cache-aside loads data into the cache only on misses, write-through writes synchronously to both cache and database, and write-behind writes to the database asynchronously. Write-behind offers the lowest latency but risks data loss if the cache crashes.

Does this approach work with Prisma, TypeORM, or SQLAlchemy?▼

Yes, the principles apply to any existing stack including Prisma, TypeORM, SQLAlchemy, and CoreData. The Skill explicitly detects the project's current tooling and never forces a migration to a different ORM or database.

Why does my cache cause database spikes when keys expire?▼

This is a cache stampede, where many instances rebuild an expired hot key concurrently and saturate the database. Mitigate it with mutex locking via Redis SETNX around rebuilds or probabilistic early expiration that refreshes keys slightly before expiry.

When should I use ACID versus BASE consistency models?▼

Use ACID databases like PostgreSQL for financial records, orders, and inventory requiring strong consistency. Use BASE-style eventually consistent systems for high-throughput workloads like activity logs, chats, and clickstream metrics.