optify-config 1.22.3-x86_64-linux → 1.23.0-x86_64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15484b0d54fc7325f04828c65d8896556adbd52a807480f5e5bb28408cf8cf8a
4
- data.tar.gz: e13e220936f918e97b6ccbc304c10602a18e916962fc89bf7b49ada6f080ea9d
3
+ metadata.gz: 36849131ee76c03ca491e65b27045dc5f2c84a151ae32de8e0c89db3e8a41e3e
4
+ data.tar.gz: 0beedff38b332b5756810a22f654a383d27e1ef120d0f7d4340dc940ec1431c2
5
5
  SHA512:
6
- metadata.gz: 1566302118bceb0a3a98ca21a5dfc7709a08e060dc84df5bb8c4a093ac8d780a3fcf0ded2ed0c4f1743faadcb5d917446b4863c56a83f060822491a9d1637f41
7
- data.tar.gz: '069c7e64b82d4ee8cfdb9db8de217f13fca75f8e576262c2d9633b1b7afcf4f8d4ffdb135f251df164656b27c9ff2ca2148b54170396e5c96220078d4ada344b'
6
+ metadata.gz: d0c77421d2ee266dee02487225ad233644c56f2910bdab5c90025086c3eab4216d6f9d84260bc8fe58185d69c35cefe89577fedcb2329f451865383e80297306
7
+ data.tar.gz: b73ab36488fa1c75efff9dfecbc9b23f5616ce26483e07cf056c249c69f53da28d8e8b3e8ad7932dec1fe359e602e9015075415dcdd9452bf464974f9299b458
Binary file
Binary file
@@ -11,8 +11,16 @@ require_relative './provider_module'
11
11
  # Tools for working with configurations declared in files.
12
12
  module Optify
13
13
  # Options for caching.
14
- # Only enabling or disabling caching is supported for now.
15
- class CacheOptions < FromHashable
14
+ class CacheOptions
15
+ #: (^(Array[untyped] key, untyped value, bool is_cache_hit) -> void)?
16
+ attr_accessor :on_cache_event
17
+
18
+ #: (
19
+ #| ?on_cache_event: (^(Array[untyped] key, untyped value, bool is_cache_hit) -> void)?,
20
+ #| ) -> void
21
+ def initialize(on_cache_event: nil)
22
+ @on_cache_event = on_cache_event
23
+ end
16
24
  end
17
25
 
18
26
  # Provides configurations based on keys and enabled feature names.
@@ -8,17 +8,23 @@ require 'sorbet-runtime'
8
8
  module Optify
9
9
  # @!visibility private
10
10
  module ProviderModule
11
- #: [T] (LruRedux::Cache | Hash[untyped, untyped], Array[untyped]) { -> T } -> T
12
- def self._cache_getset(cache, cache_key, &block)
13
- if cache.is_a? LruRedux::Cache
14
- cache.getset(cache_key, &block)
15
- else
16
- # Plain Hash - use fetch with block and store result
17
- cache.fetch(cache_key) do
18
- result = block.call
19
- cache[cache_key] = result
20
- end
21
- end
11
+ #: [T] (LruRedux::Cache | Hash[Array[untyped], T], Array[untyped], (^(Array[untyped] key, T value, bool is_cache_hit) -> void)?) { -> T } -> T
12
+ def self._cache_getset(cache, cache_key, on_cache_event, &block)
13
+ is_cache_hit = true #: bool
14
+ result = if cache.is_a? LruRedux::Cache
15
+ cache.getset(cache_key) do
16
+ is_cache_hit = false
17
+ block.call
18
+ end
19
+ else
20
+ # Plain Hash - use fetch with block and store result
21
+ cache.fetch(cache_key) do
22
+ is_cache_hit = false
23
+ cache[cache_key] = block.call
24
+ end
25
+ end
26
+ on_cache_event&.call(cache_key, result, is_cache_hit)
27
+ result
22
28
  end
23
29
 
24
30
  #: (CacheInitOptions?) -> ( Hash[Array[untyped], untyped] | LruRedux::Cache)
@@ -109,8 +115,8 @@ module Optify
109
115
  .from_hash(hash)
110
116
  end
111
117
 
112
- #: [Config] (String key, Array[String] feature_names, Class[Config] config_class, Optify::CacheOptions _cache_options, ?Optify::GetOptionsPreferences? preferences) -> Config
113
- def _get_options_with_cache(key, feature_names, config_class, _cache_options, preferences = nil)
118
+ #: [Config] (String, Array[String], Class[Config], Optify::CacheOptions, ?Optify::GetOptionsPreferences? ) -> Config
119
+ def _get_options_with_cache(key, feature_names, config_class, cache_options, preferences = nil)
114
120
  # Cache directly in Ruby instead of Rust because:
115
121
  # * Avoid any possible conversion overhead.
116
122
  # * Memory management: probably better to do it in Ruby for a Ruby app and avoid memory in Rust.
@@ -133,6 +139,7 @@ module Optify
133
139
  ProviderModule._cache_getset(
134
140
  @cache, #: as !nil
135
141
  cache_key,
142
+ cache_options.on_cache_event,
136
143
  ) do
137
144
  # Handle a cache miss.
138
145
 
data/rbi/optify.rbi CHANGED
@@ -19,8 +19,33 @@ module Optify
19
19
  end
20
20
 
21
21
  # Options for caching.
22
- # Only enabling or disabling caching is supported for now.
23
- class CacheOptions < FromHashable
22
+ class CacheOptions
23
+ sig do
24
+ returns(
25
+ T.nilable(
26
+ T.proc.params(
27
+ key: T::Array[T.untyped],
28
+ value: T.untyped,
29
+ is_cache_hit: T::Boolean,
30
+ )
31
+ .void,
32
+ ),
33
+ )
34
+ end
35
+ attr_reader :on_cache_event
36
+
37
+ sig do
38
+ params(
39
+ on_cache_event: T.nilable(
40
+ T.proc.params(
41
+ key: T::Array[T.untyped],
42
+ value: T.untyped,
43
+ is_cache_hit: T::Boolean,
44
+ ).void,
45
+ ),
46
+ ).void
47
+ end
48
+ def initialize(on_cache_event: nil); end
24
49
  end
25
50
 
26
51
  # The mode for the cache.
data/sig/optify.rbs CHANGED
@@ -17,8 +17,9 @@ class Optify::BaseConfig < FromHashable
17
17
  end
18
18
 
19
19
  # Options for caching.
20
- # Only enabling or disabling caching is supported for now.
21
- class Optify::CacheOptions < FromHashable
20
+ class Optify::CacheOptions
21
+ def initialize: () -> (^(::Array[untyped] key, untyped value, bool is_cache_hit) -> void)?
22
+ | (?on_cache_event: (^(::Array[untyped] key, untyped value, bool is_cache_hit) -> void)? on_cache_event) -> void
22
23
  end
23
24
 
24
25
  # The mode for the cache.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optify-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.22.3
4
+ version: 1.23.0
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Justin D. Harris
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-06-29 00:00:00.000000000 Z
11
+ date: 2026-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: optify-from_hash