Skip to content

v1.4.0

Choose a tag to compare

@github-actions github-actions released this 02 Jun 15:48
· 21 commits to main since this release

SafeMemoize 1.4.0

Added

  • safe_memoize_options(**opts) class-level macro — sets default options for every subsequent memoize call on the class. Per-call options take precedence; class defaults take precedence over global SafeMemoize.configure defaults. Accepts all memoize options except mode-switch options (shared:, fiber_local:, ractor_safe:, shared_cache:), which must be specified per call. Call with no arguments to clear class-level defaults.
  • copy_on_read: true option on memoize — returns a dup (or deep_dup when available, e.g. ActiveRecord objects) of the cached value on every read, preventing callers from mutating shared cached state. nil and frozen values are returned as-is. Works across all cache paths (per-instance, LRU, shared, fiber-local, and external store). Incompatible with ractor_safe: (ractor-safe values are always frozen; use that guarantee instead). Can be set as a class default via safe_memoize_options copy_on_read: true.