Skip to main content
Swytch Documentation
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Keys and Values

Cache a response or store a small value with the same SET and GET calls your Redis client uses.

SET product:42 '{"name":"tea"}' EX 300
GET product:42
TTL product:42
DEL product:42

The expiration bounds how long the cached value is useful. Your application still needs a cache-miss path: eviction or loss of the last memory-only holder can remove data before that expiration.

Use INCR for numeric counters. For a compare-and-set update, use SET with IFEQ:

SET job:42:status pending
SET job:42:status running IFEQ pending

The second command changes the value only if it is still pending. It returns OK on success or null if the condition fails. The comparison and update happen in one command.

IFNE updates when the current value differs; IFDEQ and IFDNE compare value digests. Swytch supports these conditional SET options. Use a transaction or supported script for decisions spanning multiple operations or keys.

See the key command reference and session and counter patterns.