github alisaifee/coredis 6.0.0

11 hours ago

This release is a major architectural rewrite focused on structured concurrency,
predictable resource lifetimes, and safer defaults. See the
Migration guide
for upgrade instructions.

Features

  • Migrate entire library to anyio, adding structured concurrency and trio support

  • Command API

    • Allow chainable coredis.commands.CommandRequest.transform method to accept inline callbacks
      to transform command responses
    • Added coredis.commands.CommandRequest.retry chainable method to the response from all commands
      to allow using retry policies individually with a request instead of having to apply it on all requests
      issued by a client
  • Pipeline

    • Pipelines execute automatically when their context exits - results are accessible in a type-safe way
    • Cluster pipelines now support coredis.commands.Script instances
  • Scripting

    • coredis.commands.Script and coredis.commands.Function can now be called with
      optional callbacks to transform the raw response from redis before returning it. This is supported
      by their associated coredis.commands.Script.wraps decorators as well.
    • Responses from coredis.commands.Script and coredis.commands.Function instances can now
      also be used with coredis.commands.CommandRequest.transform or coredis.commands.CommandRequest.retry.
    • Add a coredis.commands.function.wraps.verify_existence flag to library
      coredis.commands.function.wraps to optionally skip local validation and optimistically call it
  • Retry Policies

    • Retry policies now allow infinite retries & retry deadlines.
    • Retry policies now support retrying when the raised ExceptionGroup contains a matching exception
    • coredis.retry.ExponentialBackoffRetryPolicy now supports coredis.retry.ExponentialBackoffRetryPolicy.jitter
  • Miscellaneous

    • coredis.Redis.lock added as a convenient accessor
      for the Lua-based lock: coredis.patterns.lock.Lock (Previously found in coredis.recipes.LuaLock)
    • Add coredis.Redis.xconsumer factory method to create a single or group stream consumer
    • Improve guarantees of calling subscription methods on coredis.patterns.pubsub.PubSub instances.
      Using a coredis.patterns.pubsub.PubSub.subscription_timeout, the acknowledgement
      of subscription to a topic or pattern can be guaranteed before proceeding with listening to messages

Breaking Changes

  • All classes (clients, connection pools, PubSub, pipelines, stream consumers, Sentinel clients) must be
    used with their async context managers for initialization/cleanup. This ensures a predictable and
    unified resource lifecycle management model.

  • Users should replace coredis.cache.TrackingCache with coredis.patterns.cache.LRUCache when
    providing a cache instance to the clients. Cache size can no longer be bound by byte size and only
    coredis.patterns.cache.LRUCache.max_keys is supported

  • Connection pools are now always blocking. Non-blocking commands are multiplexed over shared connections and released
    back to the pool immediately after being queued and thus most workloads naturally converge to using a single active connection.
    Pool exhaustion mainly occurs when the workload relies on blocking operations (e.g. pubsub, pipelines, blocking list commands),
    making a unified blocking model simpler and more predictable. The explicit blocking variants coredis.BlockingConnectionPool
    and coredis.BlockingClusterConnectionPool have been removed.

  • Connection pool acquisition timeouts now raise TimeoutError instead of
    coredis.exceptions.ConnectionError.

  • Pipeline

    • Pipeline instances can no longer be awaited and must be used as async context managers
    • Pipelines no longer expose an explicit coredis.patterns.pipeline.Pipeline.execute method and instead
      execute automatically when their context exits
    • coredis.Redis.pipeline is no longer an async method
    • The watches parameter has been removed from the pipeline constructor
    • Drop support for explicit management of WATCH,
      UNWATCH, MULTI in pipelines. This is replaced by the coredis.patterns.pipeline.Pipeline.watch context manager.
  • Stream consumers can no longer be awaited and must be used as async context managers to ensure initialization

  • coredis.Redis.pubsub, coredis.RedisCluster.pubsub &
    coredis.RedisCluster.sharded_pubsub now only accept keyword arguments

  • When defining type stubs for FFI for Lua scripts or library functions, keys can only be distinguished
    from arguments by annotating them with coredis.typing.KeyT

  • Module reorganization

    • Move Pub/Sub, Pipeline, Stream, Cache and Lock submodules to coredis.patterns
    • coredis.commands.pubsubcoredis.patterns.pubsub
    • coredis.pipelinecoredis.patterns.pipeline
    • coredis.streamcoredis.patterns.streams
    • coredis.cachecoredis.patterns.cache
    • coredis.lockcoredis.patterns.lock

Removals

  • Drop support for RESP version 2
  • Remove coredis.commands.Monitor wrapper
  • Remove coredis.modules.RedisGraph module support

Compatibility

  • The clients no longer check if a module is loaded at initialization. Therefore a module command issued
    against a server that doesn't have the module will not fail early and instead result in an
    coredis.exceptions.UnknownCommandError exception being raised
  • Add coredis.modules.response.aggregation.AggregationType.COUNTALL and
    coredis.modules.response.aggregation.AggregationType.COUNTNAN aggregation types to
    coredis.modules.TimeSeries
  • Add coredis.modules.Search.create.indexall argument to coredis.modules.Search.create
  • Add coredis.Redis.vsim.nothread argument to coredis.Redis.vsim
  • Add support for VRANGE vector set command (coredis.Redis.vrange)
  • Add support for FT.HYBRID search command (coredis.modules.Search.hybrid)

Don't miss a new coredis release

NewReleases is sending notifications on new releases.