Cache
by @xueyetianya
Manage a local key-value cache store using bash and Python. Use when caching API responses, session data, or computed results with TTL support.
clawhub install cacheπ About This Skill
version: "1.0.0" author: BytesAgain homepage: https://bytesagain.com source: https://github.com/bytesagain/ai-skills description: "Manage a local key-value cache store using bash and Python. Use when caching API responses, session data, or computed results with TTL support."
Cache β Local Key-Value Cache Manager
A lightweight, file-backed key-value cache with TTL (time-to-live) support, search, bulk import/export, and statistics. Ideal for caching API responses, computed results, or any ephemeral data that benefits from quick local retrieval.
Prerequisites
Data Storage
Cache entries are stored in ~/.cache-tool/data.jsonl (note: uses cache-tool to avoid conflicts with ~/.cache). Each line is a JSON object with fields: key, value, ttl, created_at, expires_at, tags, etc.
Configuration lives in ~/.cache-tool/config.json.
Commands
Run via: bash scripts/script.sh
| Command | Description |
|---|---|
| set | Store a key-value pair with optional TTL and tags |
| get | Retrieve the value for a given key |
| delete | Remove a key from the cache |
| list | List all cache entries (with optional tag filter) |
| flush | Delete all cache entries or those matching a pattern |
| ttl | Check or update the TTL for an existing key |
| stats | Show cache statistics (size, hit/miss ratio, memory) |
| export | Export the cache to a JSON file |
| import | Import cache entries from a JSON file |
| search | Search keys or values by substring or regex |
| config | View or update cache settings (default TTL, max size) |
| help | Show usage information |
| version | Print the tool version |
Usage Examples
# Set a simple key-value pair
bash scripts/script.sh set --key api_response --value '{"status":"ok"}' --ttl 3600Set with tags
bash scripts/script.sh set --key user:42 --value '{"name":"Kelly"}' --tags user,profileGet a value
bash scripts/script.sh get --key api_responseDelete a key
bash scripts/script.sh delete --key old_dataList all entries
bash scripts/script.sh listList entries by tag
bash scripts/script.sh list --tag userCheck remaining TTL
bash scripts/script.sh ttl --key api_responseUpdate TTL
bash scripts/script.sh ttl --key api_response --set 7200Flush all entries
bash scripts/script.sh flushFlush by pattern
bash scripts/script.sh flush --pattern "user:*"Search by key pattern
bash scripts/script.sh search --query "api_" --field keyShow cache stats
bash scripts/script.sh statsExport cache
bash scripts/script.sh export --output cache_backup.jsonImport cache
bash scripts/script.sh import --input cache_backup.jsonConfigure defaults
bash scripts/script.sh config --set default_ttl=3600 --set max_entries=10000
Notes
get and purged during flush or stats.search command supports both simple substring matching and Python regex patterns.import merges entries; existing keys are overwritten.stats reports total entries, expired count, active count, and approximate data size.Output Format
get returns the raw value to stdout. All other commands return JSON objects with status and metadata.
Powered by BytesAgain | bytesagain.com | hello@bytesagain.com
βοΈ Configuration
π Tips & Best Practices
get and purged during flush or stats.search command supports both simple substring matching and Python regex patterns.import merges entries; existing keys are overwritten.stats reports total entries, expired count, active count, and approximate data size.