Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ Because ReRu is pre-1.0, minor versions may include breaking changes.
- Hash field deadlines are capped at the 46-bit millisecond range Redis uses:
larger `HEXPIRE`/`HPEXPIRE`/`HEXPIREAT`/`HPEXPIREAT`/`HSETEX`/`HGETEX` values
report `invalid expire time in '<cmd>' command`. `HTTL` rounds the remaining
time up to the next second. A legacy AOF with a larger stored deadline is
clamped during replay so the server still starts.
time up to the next second, and `HEXPIRETIME` rounds the absolute second up.
A legacy AOF with a larger stored deadline is clamped during replay so the
server still starts.
- `PUBSUB NUMPAT` reads a reference-counted pattern map instead of rebuilding a
set of every listener's patterns on each call.
- `BZPOPMIN`, `BZPOPMAX`, and `BZMPOP` stay blocked when a watched key only
Expand Down
2 changes: 1 addition & 1 deletion docs/COMPATIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tests; it does not certify complete compatibility with Redis.
| Strings/cache | `SET`, `GET`, `INCR`, `GETEX`, `GETDEL`, `MGET`, `MSET`, `MSETNX`, `APPEND`, `STRLEN`, `SETNX`, `SETEX`, `PSETEX`, `GETSET`, `INCRBY`, `INCRBYFLOAT`, `DECR`, `DECRBY`, `GETRANGE`, `SUBSTR`, `SETRANGE`, `LCS` | Binary values; SET NX/XX/GET/EX/PX/EXAT/PXAT/KEEPTTL; GETEX expiry/PERSIST; multi-key access, numeric arithmetic and byte ranges; longest common subsequence with LEN/IDX/MINMATCHLEN/WITHMATCHLEN |
| Lists | `RPUSH`, `LPUSH`, `LPUSHX`, `RPUSHX`, `LRANGE`, `LLEN`, `LINDEX`, `LSET`, `LINSERT`, `LTRIM`, `LREM`, `LPOS`, `LPOP`, `RPOP`, `RPOPLPUSH`, `LMOVE`, `BLPOP`, `BRPOP`, `BLMOVE`, `BRPOPLPUSH`, `LMPOP`, `BLMPOP` | Multiple elements, negative indexes, edits, moves, position search, single/multi-key blocking pops and moves with timeout |
| Streams | `XADD`, `XRANGE`, `XREVRANGE`, `XREAD`, `XLEN`, `XDEL`, `XTRIM`, `XGROUP CREATE`, `XGROUP SETID`, `XGROUP DESTROY`, `XGROUP CREATECONSUMER`, `XGROUP DELCONSUMER`, `XREADGROUP`, `XACK`, `XPENDING`, `XCLAIM`, `XAUTOCLAIM`, `XINFO GROUPS`, `XINFO CONSUMERS`, `XINFO STREAM`, `XSETID` | IDs, ranges, deletion, exact trimming, blocking reads, consumer groups, pending entries, acknowledgement, claiming and diagnostics; XADD NOMKSTREAM/MAXLEN/MINID. XRANGE with COUNT 0 or a negative count returns a null array for an existing stream and an empty array for a missing key; XREAD/XREADGROUP treat COUNT 0 or a negative count as unlimited |
| Hashes | `HSET`, `HMSET`, `HSETNX`, `HGET`, `HMGET`, `HGETALL`, `HDEL`, `HEXISTS`, `HLEN`, `HKEYS`, `HVALS`, `HINCRBY`, `HINCRBYFLOAT`, `HSTRLEN`, `HRANDFIELD`, `HSCAN`, `HEXPIRE`, `HPEXPIRE`, `HEXPIREAT`, `HPEXPIREAT`, `HTTL`, `HPTTL`, `HEXPIRETIME`, `HPEXPIRETIME`, `HPERSIST`, `HGETEX`, `HSETEX` | Binary fields/values, multiple field updates, missing-field nil replies, increments, cursor iteration, per-field expiry and conditional TTL changes; HSETEX/HGETEX/HEXPIRE accept options before or after FIELDS, field deadlines use Redis's 46-bit millisecond cap, and HTTL rounds up |
| Hashes | `HSET`, `HMSET`, `HSETNX`, `HGET`, `HMGET`, `HGETALL`, `HDEL`, `HEXISTS`, `HLEN`, `HKEYS`, `HVALS`, `HINCRBY`, `HINCRBYFLOAT`, `HSTRLEN`, `HRANDFIELD`, `HSCAN`, `HEXPIRE`, `HPEXPIRE`, `HEXPIREAT`, `HPEXPIREAT`, `HTTL`, `HPTTL`, `HEXPIRETIME`, `HPEXPIRETIME`, `HPERSIST`, `HGETEX`, `HSETEX` | Binary fields/values, multiple field updates, missing-field nil replies, increments, cursor iteration, per-field expiry and conditional TTL changes; HSETEX/HGETEX/HEXPIRE accept options before or after FIELDS, field deadlines use Redis's 46-bit millisecond cap, HTTL rounds up, and HEXPIRETIME rounds the absolute second up |
| Sets | `SADD`, `SREM`, `SISMEMBER`, `SMISMEMBER`, `SMEMBERS`, `SCARD`, `SMOVE`, `SPOP`, `SRANDMEMBER`, `SUNION`, `SINTER`, `SINTERCARD`, `SDIFF`, `SUNIONSTORE`, `SINTERSTORE`, `SDIFFSTORE`, `SSCAN` | Binary members, deduplication, membership, cardinality, random selection, atomic moves, set algebra and cursor iteration; SINTERCARD LIMIT |
| Sorted sets | `ZADD`, `ZINCRBY`, `ZCARD`, `ZSCORE`, `ZRANK`, `ZREVRANK`, `ZRANGE`, `ZREVRANGE`, `ZRANGESTORE`, `ZRANGEBYSCORE`, `ZREVRANGEBYSCORE`, `ZRANGEBYLEX`, `ZREVRANGEBYLEX`, `ZCOUNT`, `ZLEXCOUNT`, `ZREM`, `ZREMRANGEBYSCORE`, `ZREMRANGEBYRANK`, `ZREMRANGEBYLEX`, `ZMSCORE`, `ZSCAN`, `ZPOPMIN`, `ZPOPMAX`, `ZMPOP`, `BZMPOP`, `BZPOPMIN`, `BZPOPMAX`, `ZUNION`, `ZUNIONSTORE`, `ZINTER`, `ZINTERSTORE`, `ZDIFF`, `ZDIFFSTORE`, `ZINTERCARD` | Score-ordered members, rank, score and lex ranges, ZADD NX/XX/GT/LT/CH/INCR, cursor iteration, range removal, ordered and multi-key blocking pops, weighted algebra and destination storing |
| Vector sets | `VADD`, `VCARD`, `VDIM`, `VEMB`, `VREM`, `VSIM` | Bounded VALUES/FP32 inserts, Q8 or NOQUANT storage, binary members, exact `VSIM ... TRUTH` with COUNT and WITHSCORES |
Expand Down
3 changes: 2 additions & 1 deletion src/collections/hash_expiry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,8 @@ fn execute_inner(kind: Kind, command: &[Vec<u8>], store: &Store) -> Result<Vec<u
Kind::Expiretime | Kind::Pexpiretime => old.map(|at| {
let millis = at.unix_ms;
if matches!(kind, Kind::Expiretime) {
millis / 1000
// Redis rounds the absolute second up.
millis.saturating_add(999) / 1000
} else {
millis
}
Expand Down
36 changes: 36 additions & 0 deletions tests/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,42 @@ fn hash_expiry_deadline_range_and_ttl_rounding() {
invalid("hgetex")
);

// HEXPIRETIME rounds the absolute second up; HPEXPIRETIME keeps the millis.
let base = (SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_millis() as u64
/ 1000
+ 100)
* 1000;
for offset in [0u64, 1, 499, 500, 501, 999, 1000] {
let deadline = base + offset;
assert_eq!(
c.call(&[
b"HPEXPIREAT",
b"h",
deadline.to_string().as_bytes(),
b"FIELDS",
b"1",
b"f",
]),
array(vec![integer(1)])
);
assert_eq!(
c.call(&[b"HPEXPIRETIME", b"h", b"FIELDS", b"1", b"f"]),
array(vec![integer(deadline as i64)])
);
assert_eq!(
c.call(&[b"HEXPIRETIME", b"h", b"FIELDS", b"1", b"f"]),
array(vec![integer(deadline.div_ceil(1000) as i64)]),
"{offset}"
);
}
assert_eq!(
c.call(&[b"HEXPIRETIME", b"h", b"FIELDS", b"1", b"f"]),
array(vec![integer(((base + 1000) / 1000) as i64)])
);

// A rejected value leaves the existing TTL and field untouched.
assert_eq!(
c.call(&[b"HPEXPIRE", b"h", b"100000", b"FIELDS", b"1", b"f"]),
Expand Down
Loading