Skip to content

Releases

v0.4.2

Choose a tag to compare

@dcbickfo dcbickfo released this 24 Nov 21:05
7bea46c

Added

  • RedisError can now receive op="read_fallback", which Metrics
    implementations and dashboards that enumerate operations or alert on all
    redis.errors need to account for.
    It counts an attempted uncached retry after a clustered cached read
    aborted. It emits one event per uncached retry attempt, whether for one key
    or a batch. A polling Get or GetMulti can make more than one attempt.
    The count includes retries that fail, return Redis nil, or are canceled
    before sending. Missing PTTL permission can trigger an abort. A
    sustained rate alone cannot identify a server-side EXEC abort because
    rueidis also reports ErrDoCacheAborted when a connection closes.

Fixed

  • Fixed cache misses that could wait for a lock nobody held after a read
    without client-side tracking.
  • Cache reads can refill a missing key after a loader or write callback panics.
  • Cached reads follow ASK during Valkey 9 cluster slot migration.

v0.4.1

Choose a tag to compare

@dcbickfo dcbickfo released this 13 Nov 02:30
0d36768

Fixed

  • A Get or GetMulti loader slower than LockTTL no longer loops
    forever.
    The Redis lock was never extended while the loader ran, so the
    lock expired, the final CAS-set failed with ErrLockLost, and the call
    retried, re-running the loader indefinitely. The lock is now extended every
    LockTTL/3 for as long as the loader runs, and a call that loses its lock
    more than three times returns ErrLockLost instead of retrying again.
  • Set and SetMulti roll back when the callback panics. A callback
    that panicked, with the panic recovered by the caller, left the write lock in
    place for LockTTL and the prior value gone. The prior values are now
    restored before the panic continues.
  • A rollback no longer persists a value that was about to expire. When the
    prior value had under a millisecond of TTL left (PTTL 0), the restore wrote
    it back with no expiry. It now deletes the key. Values with no expiry
    (PTTL -1) are still restored without one.

Documentation

  • README: write-through Set section covering the restore-on-error
    precondition and how to handle ErrLockLost.

v0.4.0

Choose a tag to compare

@dcbickfo dcbickfo released this 02 Nov 15:20
9b8e07f

Breaking

  • Go 1.27 is now required. The module, local toolchain pin, and CI all
    target Go 1.27.
  • Cache[K, V] is replaced by the non-generic Cache. Both type
    parameters move to the operations as Go 1.27 generic methods — Get[K, V],
    GetMulti[K, V], Peek[K, V], Set[K, V], SetMulti[K, V],
    ForceSet[K, V], ForceSetMulti[K, V], Del[K], DelMulti[K],
    Touch[K], TouchMulti[K] — so one cache serves every key and value type.
    Keys and loaders normally infer both; Peek needs explicit Peek[K, V]
    (nothing to infer V from), and an untyped nil passed to a multi-key method
    needs explicit type arguments.
  • Constructors are New(conn, valCodec), NewKeyed(conn, keyCodec, valCodec), and NewBytes(conn). New[K] and NewString are gone.
  • Codec[V] and KeyCodec[K] are replaced by any-based Codec and
    KeyCodec.
    A codec decodes into the operation's *V, following the
    encoding/json destination pattern; mismatches are returned as errors.
    StringKeyCodec (the New default) accepts string, any ~string type,
    and encoding.TextMarshaler; KeyCodecFunc[K] accepts exactly K.
    String-underlying key types now take the zero-copy multi-key fast path that
    was previously limited to K == string.
  • No interface form; redcachetest is removed. Generic methods cannot
    satisfy Go interfaces, so Cache is the only type and code under test takes
    *Cache. OpenMemory(opts ...MemoryOption) replaces the fake: it returns a
    Conn backed by an in-process map, so tests build a real Cache with real
    codecs over it. WithMemoryClock replaces redcachetest.Clock.

Added

  • JSONV2Codec — opt-in encoding/json/v2 codec (nil slices/maps as []/{},
    case-sensitive field matching, duplicate object names rejected). JSONCodec
    keeps encoding/json v1 semantics and wire format.
  • The test binary's TestMain fails the run on any leaked package goroutine,
    using Go 1.27's goroutineleak profile; TestConn_Close_LeaksNoGoroutines
    pins the same check to Conn.Close.

Fixed

  • A Get/GetMulti leader that exits on error (cancelled context, Redis
    error) releases its local wait entry. Later callers in the same process used
    to park on it until LockTTL, since nothing was written to invalidate it.
  • Set/SetMulti that fail before writing to Redis (cancelled context, read
    error) release the local wait entries they created. A Get/GetMulti on
    the same key used to park on such an entry until LockTTL.
  • rueidis's nil invalidation (connection lost, FLUSHALL/FLUSHDB) now wakes
    every local waiter. It was ignored, so after a Redis restart or flush the next
    miss on a recently-read key could stall until LockTTL.
  • A ttl under 1ms returns ErrInvalidTTL up front instead of running the
    loader and then failing on Redis PX 0.
  • ForceSetMulti with two keys that encode to the same Redis key returns a
    plain error and writes nothing, matching SetMulti/GetMulti. It used to
    return a *BatchKeyError listing only the colliding keys, which implied the
    rest had been written.
  • *BatchKeyError implements Unwrap() []error, so errors.Is(err, context.Canceled) and errors.Is(err, ErrLockLost) work on multi-key
    writes as they do on single-key ones.
  • OpenMemory now matches the Redis engine: it drops loader results for keys
    that were not requested, dedupes input keys, and copies stored values
    instead of aliasing the caller's buffer.
  • GetMulti retry loop no longer races a still-running lock waiter: the
    internal WaitForAll goroutine is joined before the poll fallback returns,
    so the reused channel slice is not rewritten underneath it (found by the race
    detector; pre-existing).

Changed

  • github.com/google/uuid is replaced by the Go 1.27 standard-library uuid
    package; the module has one fewer direct dependency.
  • Concurrent worker launches use sync.WaitGroup.Go, typed error matching uses
    errors.AsType, and tests use t.Context(), b.Loop(), and stdlib
    slices sorting. internal/syncx timing tests run in testing/synctest
    bubbles instead of racing wall-clock deadlines.
  • golangci-lint is updated to v2.15.0, retaining the full lint and formatting
    gates with Go 1.27 generic-method support. The config enables revive's new
    use-slices-concat, marshal-receiver, and multiline-if-init rules, sets
    exclusions.warn-unused, and drops exclusion rules that no longer matched
    anything (vendor paths, a stale gosec G115 rule, and the redefines-builtin-id
    waiver, whose one hit was renamed).
  • Multi-key paths (GetMulti, SetMulti, TouchMulti, lock acquire,
    CAS-set and unlock) send each phase as one pipeline instead of one pipeline
    and goroutine per cluster slot. Every script touches a single key, and
    rueidis's cluster client already splits a pipeline per node, runs the nodes
    in parallel and follows redirects, so a batch now costs one round trip per
    node rather than per slot. internal/cmdx is deleted.

v0.3.1

Choose a tag to compare

@dcbickfo dcbickfo released this 31 Oct 17:56
e812e0a

A patch release for the v0.3 line, backported from the v0.4 work. The rueidis
version is unchanged.

Changed

  • The Go floor is now 1.26.10 (go 1.26.10 in go.mod), up from 1.25. Go
    1.25 is out of support and has unfixed standard-library vulnerabilities in
    crypto/tls and crypto/x509 (GO-2026-6607, GO-2026-6809); 1.26.10 is the
    first release with both fixes. CI tests on Go 1.26 and 1.27.
  • go fix modernizers for Go 1.26 are applied (wg.Go, range over ints,
    min/max), with no behavior change.
  • CI now runs the suite against a Redis Cluster, covering slot migration
    (MOVED and ASK), primary failover, and per-node SCRIPT LOAD counts.

Added

  • ErrMissingValue, returned (wrapped, naming the keys) when a GetMulti or
    SetMulti loader returns no value for a key it was given.

Fixed

  • Multi-key operations no longer recycle the command slice passed to rueidis
    DoMulti. On context cancellation rueidis's writer goroutine could still be
    reading it, and the pooled reset crashed the process with a nil-pointer
    panic. Standalone and sentinel clients were affected, because they hand the
    caller's slice to the connection; the cluster client copies commands into
    per-node slices first, so cluster deployments were not.
  • GetMulti no longer livelocks when its loader omits a key. It used to
    re-lock the key and re-run the loader until the context ended; it now fails
    fast with ErrMissingValue. SetMulti reports omitted keys as failed with
    ErrMissingValue (restoring their prior value) instead of returning nil.
    redcachetest.Fake follows the same contract.
  • Multi-key Lua calls (GetMulti misses, SetMulti, TouchMulti,
    multi-key refresh) no longer send SCRIPT LOAD to every node, replicas
    included, and wait for it before every batch. They pipeline EVALSHA and
    re-send only NOSCRIPT replies as EVAL, saving about one round trip per
    call (the slowest node's, on a cluster).

v0.3.0

Choose a tag to compare

@dcbickfo dcbickfo released this 19 Jun 12:23
4e69d68

Highlights

  • Introduces the generics-first Cache[K, V] API, derived from a shared Conn
    with New, NewString, or NewBytes.
  • Adds typed codecs, redcachetest.Fake[K, V], the redcacheotel metrics
    adapter, and standalone examples under examples/.
  • Hardens refresh and write paths with lock-wait polling fallback, refresh
    timeout control, TTL validation, and typed key collision checks.
  • Raises the minimum Go version to 1.25 and adds CI/security automation.

Breaking Changes

  • Replace NewRedCacheAside / NewPrimeableCacheAside and CacheAsideOption
    with Open plus functional options, then derive cache views from the Conn.
  • Cache views are operations-only; Close() and raw Client() access now live
    on Conn.
  • Multi-key mutation methods now take []K, Metrics implementers need the new
    loader/Redis hooks, and BytesCodec is now UnsafeBytesCodec.

The on-disk value format is unchanged from v0.2.x. See the README migration
section for concrete v0.2.x -> v0.3.x examples.

v0.2.0

Choose a tag to compare

@dcbickfo dcbickfo released this 04 May 21:50
3a08039

What's Changed

  • Add XFetch probabilistic refresh (RefreshBeta), Touch/TouchMulti API, LockWaitDuration metric, perf refactors by @dcbickfo
  • Skip duplicate SET NX under in-process contention via leader/follower coordination by @dcbickfo
  • Cut allocs in Get/GetMulti hot path by @dcbickfo
  • Switch high-volume metrics to count-based and gate noop dispatch by @dcbickfo
  • Validate LockPrefix against envelope prefix at construction by @dcbickfo

⚠️ Breaking changes

  • On-disk value format changed. Values are now wrapped in __redcache:v1:<delta_ns>:<payload> so refresh-ahead can read original compute time for XFetch sampling. Reads transparently unwrap; legacy un-wrapped values still serve (with delta=0). Rolling back from v0.2.0+ to v0.1.7 or earlier requires flushing affected keys — older clients will return the raw envelope as the user value.
  • LockPrefix is now validated at construction. Setting it such that the envelope prefix would look like a lock value returns an error from NewRedCacheAside (default __redcache:lock: is unaffected).

Full Changelog: v0.1.7...v0.2.0

v0.1.7

Choose a tag to compare

@dcbickfo dcbickfo released this 29 Apr 11:12
4e8d9fb

What's Changed

  • Fix Register, Add Linter, Add More Concurrency Tests by @dcbickfo in #6
  • Add Set/SetMulti capability via PrimeableCacheAside by @dcbickfo in #10
  • Refresh ahead by @dcbickfo in #9

Full Changelog: v0.1.6...v0.1.7

v0.1.6

Choose a tag to compare

@dcbickfo dcbickfo released this 06 Oct 20:34
0ac05db

What's Changed

Full Changelog: v0.1.5...v0.1.6

v0.1.5

Choose a tag to compare

@dcbickfo dcbickfo released this 06 Oct 19:13
4cd27f1
Fix Indefinite Wait (#4)

* adding retry for contested locks and an operation timeout

* remove operation timeout

* use context to ensure cancellation

* Update cacheaside.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

v0.1.4

Choose a tag to compare

@dcbickfo dcbickfo released this 04 Apr 16:59
6365005

What's Changed

  • Use an Iterator + Client Builder Option by @dcbickfo in #3

Full Changelog: v0.1.3...v0.1.4

⌂ 换网址