Skip to main content

Cache CLI Commands

The praisonai-ts CLI provides the cache command for managing cached values with file-based persistence.

Commands Overview

CommandDescription
cache set <key> <value>Cache a value
cache get <key>Get cached value
cache delete <key>Delete cached entry
cache listList all cached entries
cache statsShow cache statistics
cache clearClear all cache entries
cache helpShow help

Set a Value

Cache a key-value pair:
# Basic caching
praisonai-ts cache set api_response "Hello from API"

# With TTL (time-to-live in seconds)
praisonai-ts cache set token "abc123xyz" --ttl 3600

# JSON output
praisonai-ts cache set mykey "value" --json
Example Output:
✓ Cached: api_response
  TTL: 3600 seconds

Get a Value

Retrieve a cached value:
# Get cached value
praisonai-ts cache get api_response

# JSON output
praisonai-ts cache get mykey --json
Example Output:
✓ Cache hit: api_response
Hello from API
Cache Miss Output:
ℹ Cache miss: unknown_key
JSON Output:
{
  "success": true,
  "data": {
    "key": "api_response",
    "value": "Hello from API",
    "found": true
  }
}

Delete a Value

Remove a cached entry:
praisonai-ts cache delete api_response
praisonai-ts cache delete mykey --json

List All Entries

View all cached items:
praisonai-ts cache list
praisonai-ts cache list --json
Example Output:
Cache Entries

  • api_response (15 chars)
    Created: 2026-01-17T22:30:00.000Z
  • token (9 chars)
    Created: 2026-01-17T22:31:00.000Z

ℹ Total: 2 entries

Cache Statistics

View cache stats:
praisonai-ts cache stats
praisonai-ts cache stats --json
Example Output:
Cache Statistics

  Entries: 5
  Total Size: 1234 characters
  Expired: 0
  Location: ~/.praisonai/cache
JSON Output:
{
  "success": true,
  "data": {
    "entries": 5,
    "totalSize": 1234,
    "expired": 0,
    "cacheDir": "/Users/you/.praisonai/cache"
  }
}

Clear All

Remove all cached entries:
praisonai-ts cache clear
praisonai-ts cache clear --json
Example Output:
✓ Cleared 5 cache entries

Options

OptionDescriptionDefault
--ttl <seconds>Time-to-live for cache entryNo expiration
--jsonJSON outputfalse

Cache Location

Cache files are stored in:
~/.praisonai/cache/<key>.json
Each file contains:
{
  "value": "cached content",
  "createdAt": 1705123456789,
  "expiresAt": 1705127056789
}

Use Cases

API Response Caching

# Cache an API response
praisonai-ts cache set weather_data "sunny, 72F" --ttl 1800

# Retrieve later
praisonai-ts cache get weather_data

Session Tokens

# Cache authentication token with 1-hour TTL
praisonai-ts cache set auth_token "eyJhbGciOiJIUzI..." --ttl 3600

Config Values

# Cache configuration that changes infrequently
praisonai-ts cache set feature_flags '{"darkMode":true,"beta":false}'