Module: MultiJSON::OptionsCache Private
- Defined in:
- lib/multi_json/options_cache.rb,
lib/multi_json/options_cache/mutex_store.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Thread-safe bounded cache for merged options hashes
Caches are separated for load and dump operations. Each cache is
bounded to prevent unbounded memory growth when options are
generated dynamically. The Store backend is chosen at load time
based on RUBY_ENGINE: JRuby uses Concurrent::Map (shipped as a
runtime dependency of the java-platform gem); MRI and TruffleRuby
use a Hash guarded by a Mutex.
Defined Under Namespace
Classes: Store
Constant Summary collapse
- DEFAULT_MAX_CACHE_SIZE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Default bound on the number of cached entries per store. Applications that dynamically generate many distinct option hashes can raise this via max_cache_size=.
1000
Class Attribute Summary collapse
-
.dump ⇒ Store
readonly
private
Get the dump options cache.
-
.load ⇒ Store
readonly
private
Get the load options cache.
-
.max_cache_size ⇒ Integer
Maximum number of entries per cache store.
Class Method Summary collapse
-
.reset ⇒ void
private
Reset both caches.
Class Attribute Details
.dump ⇒ Store (readonly)
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.
Get the dump options cache
32 33 34 |
# File 'lib/multi_json/options_cache.rb', line 32 def dump @dump end |
.load ⇒ Store (readonly)
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.
Get the load options cache
38 39 40 |
# File 'lib/multi_json/options_cache.rb', line 38 def load @load end |
.max_cache_size ⇒ Integer
Maximum number of entries per cache store
Applies to both the dump and load caches. Existing entries are left in place until normal eviction trims them below a lowered limit; call reset if you need to evict immediately.
51 52 53 |
# File 'lib/multi_json/options_cache.rb', line 51 def max_cache_size @max_cache_size end |
Class Method Details
.reset ⇒ void
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.
This method returns an undefined value.
Reset both caches
71 72 73 74 |
# File 'lib/multi_json/options_cache.rb', line 71 def reset @dump = Store.new @load = Store.new end |