Compatibility

Compatibility with Redis #

IceFireDB speaks RESP and most commands behave as Redis does, but it is not Redis: the storage model underneath is ledis, which keeps one keyspace per data type and stores expirations in whole seconds. This page lists the differences a client will actually notice, and why they exist.

Behaviours marked locked by test are pinned by compat_test.go (make test-compat) so they cannot change without a deliberate update.

1. No WRONGTYPE — one keyspace per data type #

Redis: a key holds one value of one type; the wrong-type command fails with WRONGTYPE Operation against a key holding the wrong kind of value.

IceFireDB keeps a separate keyspace per type (string, hash, list, set, sorted set). Consequences:

  • The same key name can hold a string and a hash and a list simultaneously.
  • A type-mismatched command does not fail; it operates on that type’s own (possibly empty) view.
  • There is no TYPE command at all, so you cannot ask which type a key currently has.
SET k v          -> OK
HSET k f x       -> 1        # Redis: WRONGTYPE, here: fine
GET k            -> "v"
HGET k f         -> "x"

If your application relies on WRONGTYPE for type safety, enforce it in the application (for example with a key-naming convention such as user:1:profile vs user:1:fields).

locked by test — compat_test.go.

2. Expiration is per type #

There is no single TTL per key. Each type has its own:

TypeExpiry commandsPERSIST
StringEXPIRE, EXPIREAT, TTLnone (handler not registered)
HashHEXPIRE, HEXPIREAT, HTTLnone (handler not registered)
ListLEXPIRE, LEXPIREAT, LTTLnone (handler not registered)
SetSEXPIRE, SEXPIREAT, STTLSPERSIST (the only one)
Sorted setnone—

A sorted set cannot be given a TTL; clear it (ZCLEAR) and recreate, or keep the expiry in a string key. EXPIRE takes exactly KEY seconds — the Redis NX/XX/GT/LT options are not supported.

3. Expiration has one-second resolution #

Expirations are stored as whole seconds, so SET key value PX 500 keeps the key for 1 second and PX 1500 for 2 (Redis: 0.5 s and 1.5 s). A key never expires earlier than requested, and every *TTL reports whole seconds.

4. Empty values collapse on the decentralized backends #

HSET k f "" then HGET k f:

  • on goleveldb, badger, hybriddb: empty bulk string, as Redis;
  • on the decentralized drivers: nil — “empty” and “absent” look the same.

GET follows the same rule for string values. Do not store empty strings when “missing” must be distinguishable; store a sentinel or use a hash field’s presence.

5. Scan cursors are not integers #

  • SCAN answers an opaque base64 cursor carrying five sub-cursors (one per keyspace).
  • HSCAN/SSCAN/ZSCAN answer the last field or member name, so a field literally named 0 collides with the end marker.
  • Client helpers that parse the cursor as an integer (go-redis’ typed HScan) reject it; use the generic command API.
  • COUNT is capped at 10000, and a page may be empty while the cursor still advances.

See Scan.

6. Expiration timestamps use the Raft clock #

Every expiry is computed from the Raft machine clock (m.Now()), which keeps it identical on every replica, while the storage layer validates timestamps and reports TTL against the local wall clock. So:

  • when the Raft clock lags local time, a short-lived key can report TTL -1 although it still has a value;
  • an expiry shorter than the clock skew is rejected with invalid expire value;
  • TTL/HTTL/LTTL/STTL on different replicas can differ by their apply latency.

Long TTLs are unaffected in practice. Do not build sub-second semantics on top of this.

7. Conditional writes see the local expiry check #

Expired keys are reaped asynchronously against the local clock, and SET … NX/XX (and SETNX) test existence through that same view. A key that has logically expired may still be visible on one replica and not another, so two replicas can disagree about whether the write happens.

8. List rebuilds are not transactional #

LINSERT and LREM have no storage primitive, so the handler rebuilds the list (LRange → LClear → RPush, then restores the TTL). The rebuild happens inside one Raft apply, so no other client sees a partial list, but a backend failure halfway leaves the list truncated. Both are O(n).

9. Three sorted-set commands do not replicate #

ZINCRBY, ZREMRANGEBYRANK and ZREMRANGEBYSCORE are registered as read commands, so they mutate only the node that receives them. In a cluster that means no replication and no survival across a leader change. Use ZADD with a computed score and ZREM until this is fixed.

10. Bounded requests #

Two client-supplied numbers are bounded so one request cannot materialise an unbounded reply:

LimitValueOn violation
COUNT on any scan10000Clamped (still a hint)
`countonSRANDMEMBER`
SET … EX that would overflow int64—Error reply, the write is refused

Missing commands #

Commands people reach for that this engine does not register:

CommandInstead
SELECTNothing — one logical database
TYPETrack the type yourself; keyspaces are per type
KEYSSCAN 0 MATCH pattern COUNT n (or XSCAN)
DBSIZESCAN and count, or track it in the application
MULTI/EXEC/WATCHNo transactions; BARRIER gives read-your-writes
BLPOP/BRPOPPoll with LPOP, or use a separate queue system
MONITORNot exposed
CONFIG GET/SETCommand-line flags only; restart to change them
PERSIST (string), HPERSIST, LPERSISTEXPIRE again, or delete and rewrite
ZEXPIRE/ZTTL, ZPOPMIN/ZPOPMAXZCLEAR, ZRANGE/ZREM

Scope of this page #

This is not an exhaustive compatibility report; it captures the divergences confirmed to date. If you find another, it is worth a test in compat_test.go so it stops being accidental.