Class: SafeMemoize::Configuration
- Inherits:
-
Object
- Object
- SafeMemoize::Configuration
- Defined in:
- lib/safe_memoize/configuration.rb
Overview
Global configuration for SafeMemoize.
Obtain an instance via configure or configuration.
Instance Attribute Summary collapse
-
#active_support_notifications ⇒ Boolean
When +true+, SafeMemoize emits +ActiveSupport::Notifications+ events for cache hits, misses, stores, evictions, and expirations.
-
#default_max_size ⇒ Integer?
Default LRU size cap applied to every SafeMemoize::ClassMethods#memoize call that does not specify its own +max_size:+.
-
#default_ttl ⇒ Numeric?
Default TTL (seconds) applied to every SafeMemoize::ClassMethods#memoize call that does not specify its own +ttl:+.
-
#on_deprecation ⇒ Proc?
Custom handler for deprecation warnings.
-
#on_hook_error ⇒ Proc?
Custom handler for errors raised inside lifecycle hooks.
-
#opentelemetry_tracer ⇒ Object?
An OpenTelemetry tracer (responds to +#in_span+).
-
#statsd_client ⇒ Object?
Any StatsD-compatible client (responds to +#increment+).
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
private
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Configuration.
46 47 48 49 50 51 52 53 54 |
# File 'lib/safe_memoize/configuration.rb', line 46 def initialize @default_ttl = nil @default_max_size = nil @on_deprecation = nil @on_hook_error = nil @active_support_notifications = false @statsd_client = nil @opentelemetry_tracer = nil end |
Instance Attribute Details
#active_support_notifications ⇒ Boolean
Returns When +true+, SafeMemoize emits +ActiveSupport::Notifications+ events for cache hits, misses, stores, evictions, and expirations. Requires +activesupport+ to be loaded; has zero overhead when it is not.
35 36 37 |
# File 'lib/safe_memoize/configuration.rb', line 35 def active_support_notifications @active_support_notifications end |
#default_max_size ⇒ Integer?
Returns Default LRU size cap applied to every SafeMemoize::ClassMethods#memoize call that does not specify its own +max_size:+. +nil+ means unlimited.
21 22 23 |
# File 'lib/safe_memoize/configuration.rb', line 21 def default_max_size @default_max_size end |
#default_ttl ⇒ Numeric?
Returns Default TTL (seconds) applied to every SafeMemoize::ClassMethods#memoize call that does not specify its own +ttl:+. +nil+ means no expiry.
17 18 19 |
# File 'lib/safe_memoize/configuration.rb', line 17 def default_ttl @default_ttl end |
#on_deprecation ⇒ Proc?
Returns Custom handler for deprecation warnings. Receives a single +String+ message. When +nil+, warnings are written to +$stderr+.
25 26 27 |
# File 'lib/safe_memoize/configuration.rb', line 25 def on_deprecation @on_deprecation end |
#on_hook_error ⇒ Proc?
Returns Custom handler for errors raised inside lifecycle hooks. Receives +(Exception, Symbol hook_type, cache_key)+. When +nil+, a warning is written to +$stderr+ and the error is swallowed.
30 31 32 |
# File 'lib/safe_memoize/configuration.rb', line 30 def on_hook_error @on_hook_error end |
#opentelemetry_tracer ⇒ Object?
Returns An OpenTelemetry tracer (responds to +#in_span+). When set, Adapters::OpenTelemetry wraps each cache-miss computation in a span.
43 44 45 |
# File 'lib/safe_memoize/configuration.rb', line 43 def opentelemetry_tracer @opentelemetry_tracer end |
#statsd_client ⇒ Object?
Returns Any StatsD-compatible client (responds to +#increment+). When set, Adapters::StatsD routes lifecycle events to this client.
39 40 41 |
# File 'lib/safe_memoize/configuration.rb', line 39 def statsd_client @statsd_client end |