safe_memoize 0.7.0 → 0.9.0
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 +4 -4
- data/.github/workflows/ci.yml +29 -2
- data/.github/workflows/release.yml +5 -1
- data/CHANGELOG.md +119 -100
- data/README.md +385 -7
- data/ROADMAP.md +92 -0
- data/benchmarks/README.md +68 -0
- data/benchmarks/benchmark.rb +225 -0
- data/codecov.yml +17 -0
- data/lib/safe_memoize/adapters/opentelemetry.rb +19 -0
- data/lib/safe_memoize/adapters/statsd.rb +25 -0
- data/lib/safe_memoize/class_methods.rb +15 -4
- data/lib/safe_memoize/configuration.rb +7 -1
- data/lib/safe_memoize/hooks_methods.rb +40 -1
- data/lib/safe_memoize/inspection_methods.rb +14 -1
- data/lib/safe_memoize/public_methods.rb +43 -0
- data/lib/safe_memoize/rails/middleware.rb +23 -0
- data/lib/safe_memoize/rails/request_scoped.rb +37 -0
- data/lib/safe_memoize/rails.rb +28 -0
- data/lib/safe_memoize/version.rb +1 -1
- data/lib/safe_memoize.rb +8 -0
- data/sig/safe_memoize.rbs +32 -1
- metadata +11 -2
data/sig/safe_memoize.rbs
CHANGED
|
@@ -7,6 +7,7 @@ module SafeMemoize
|
|
|
7
7
|
type memo_key = default_memo_key | custom_memo_key
|
|
8
8
|
type memo_record = { value: untyped, expires_at: Float?, cached_at: Float }
|
|
9
9
|
|
|
10
|
+
@configuration: Configuration?
|
|
10
11
|
@__safe_memo_cache__: Hash[memo_key, memo_record]?
|
|
11
12
|
@__safe_memo_mutex__: Mutex?
|
|
12
13
|
@__safe_memo_shared_cache__: Hash[memo_key, memo_record]?
|
|
@@ -17,17 +18,23 @@ module SafeMemoize
|
|
|
17
18
|
def self.configure: () { (Configuration) -> void } -> void
|
|
18
19
|
def self.configuration: () -> Configuration
|
|
19
20
|
def self.reset_configuration!: () -> Configuration
|
|
21
|
+
def self.deprecate: (String subject, message: String, horizon: String) -> void
|
|
20
22
|
|
|
21
23
|
class Configuration
|
|
22
24
|
attr_accessor default_ttl: Numeric?
|
|
23
25
|
attr_accessor default_max_size: Integer?
|
|
26
|
+
attr_accessor on_deprecation: (^(String message) -> void)?
|
|
27
|
+
attr_accessor on_hook_error: (^(Exception error, Symbol hook_type, untyped cache_key) -> void)?
|
|
28
|
+
attr_accessor active_support_notifications: bool
|
|
29
|
+
attr_accessor statsd_client: untyped
|
|
30
|
+
attr_accessor opentelemetry_tracer: untyped
|
|
24
31
|
|
|
25
32
|
def initialize: () -> void
|
|
26
33
|
end
|
|
27
34
|
|
|
28
35
|
module ClassMethods
|
|
29
36
|
def memoize: (Symbol | String method_name, ?ttl: Numeric?, ?max_size: Integer?, ?ttl_refresh: bool, ?if: (^(untyped result) -> boolish)?, ?unless: (^(untyped result) -> boolish)?, ?shared: bool, ?key: (^(*untyped args, **untyped kwargs) -> untyped)?) -> void
|
|
30
|
-
def memoize_all: (?except: Array[Symbol | String], ?include_protected: bool, ?include_private: bool, ?ttl: Numeric?, ?max_size: Integer?, ?if: (^(untyped result) -> boolish)?, ?unless: (^(untyped result) -> boolish)?, ?shared: bool, ?key: (^(*untyped args, **untyped kwargs) -> untyped)?) -> void
|
|
37
|
+
def memoize_all: (?except: Array[Symbol | String], ?only: Array[Symbol | String], ?include_protected: bool, ?include_private: bool, ?ttl: Numeric?, ?max_size: Integer?, ?if: (^(untyped result) -> boolish)?, ?unless: (^(untyped result) -> boolish)?, ?shared: bool, ?key: (^(*untyped args, **untyped kwargs) -> untyped)?) -> void
|
|
31
38
|
def reset_shared_memo: (Symbol | String method_name, *untyped args, **untyped kwargs) -> void
|
|
32
39
|
def reset_all_shared_memos: () -> void
|
|
33
40
|
def shared_memoized?: (Symbol | String method_name, *untyped args, **untyped kwargs) -> bool
|
|
@@ -68,6 +75,7 @@ module SafeMemoize
|
|
|
68
75
|
def memo_stale?: (Symbol | String method_name, *untyped args, **untyped kwargs) -> bool
|
|
69
76
|
def reset_memo: (Symbol | String method_name, *untyped args, **untyped kwargs) -> void
|
|
70
77
|
def reset_all_memos: () -> void
|
|
78
|
+
def memo_inspect: (Symbol | String method_name, *untyped args, **untyped kwargs) -> { cached: bool, value: untyped, hits: Integer, misses: Integer, ttl_remaining: Float?, age: Float?, custom_key: untyped, lru_position: Integer? }?
|
|
71
79
|
end
|
|
72
80
|
|
|
73
81
|
module CacheStoreMethods
|
|
@@ -108,6 +116,7 @@ module SafeMemoize
|
|
|
108
116
|
def safe_memo_values_for: (Symbol? method_name) -> Array[untyped]
|
|
109
117
|
def memo_projection: (memo_key cache_key, memo_record value, include_method: bool, include_value: bool) -> Hash[Symbol, untyped]
|
|
110
118
|
def safe_memo_cache_key: (Symbol | String method_name, Array[untyped] args, Hash[Symbol, untyped] kwargs) -> default_memo_key
|
|
119
|
+
def deep_freeze_copy: (untyped obj) -> untyped
|
|
111
120
|
end
|
|
112
121
|
|
|
113
122
|
module HooksMethods
|
|
@@ -185,5 +194,27 @@ module SafeMemoize
|
|
|
185
194
|
include PublicCustomKeyMethods
|
|
186
195
|
include LruMethods
|
|
187
196
|
end
|
|
197
|
+
|
|
198
|
+
module Adapters
|
|
199
|
+
module OpenTelemetry
|
|
200
|
+
SPAN_NAME: String
|
|
201
|
+
def self.trace: (untyped tracer, Symbol | String method_name, String? class_name) { () -> untyped } -> untyped
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
module Rails
|
|
206
|
+
def self.track: (untyped instance) -> void
|
|
207
|
+
def self.reset_tracked!: () -> void
|
|
208
|
+
|
|
209
|
+
module RequestScoped
|
|
210
|
+
def self.included: (Module base) -> void
|
|
211
|
+
def reset_request_memos: () -> void
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
class Middleware
|
|
215
|
+
def initialize: (untyped app) -> void
|
|
216
|
+
def call: (untyped env) -> untyped
|
|
217
|
+
end
|
|
218
|
+
end
|
|
188
219
|
end
|
|
189
220
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: safe_memoize
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chuck Smith
|
|
@@ -34,7 +34,7 @@ description: 'SafeMemoize is a production-ready, zero-dependency memoization lib
|
|
|
34
34
|
cache key generators, and introspection helpers. Method visibility (public, protected,
|
|
35
35
|
private) is fully preserved.'
|
|
36
36
|
email:
|
|
37
|
-
-
|
|
37
|
+
- chuck@eclecticcoding.com
|
|
38
38
|
executables: []
|
|
39
39
|
extensions: []
|
|
40
40
|
extra_rdoc_files: []
|
|
@@ -44,8 +44,14 @@ files:
|
|
|
44
44
|
- CHANGELOG.md
|
|
45
45
|
- LICENSE.txt
|
|
46
46
|
- README.md
|
|
47
|
+
- ROADMAP.md
|
|
47
48
|
- Rakefile
|
|
49
|
+
- benchmarks/README.md
|
|
50
|
+
- benchmarks/benchmark.rb
|
|
51
|
+
- codecov.yml
|
|
48
52
|
- lib/safe_memoize.rb
|
|
53
|
+
- lib/safe_memoize/adapters/opentelemetry.rb
|
|
54
|
+
- lib/safe_memoize/adapters/statsd.rb
|
|
49
55
|
- lib/safe_memoize/cache_metrics_methods.rb
|
|
50
56
|
- lib/safe_memoize/cache_record_methods.rb
|
|
51
57
|
- lib/safe_memoize/cache_store_methods.rb
|
|
@@ -59,6 +65,9 @@ files:
|
|
|
59
65
|
- lib/safe_memoize/public_custom_key_methods.rb
|
|
60
66
|
- lib/safe_memoize/public_methods.rb
|
|
61
67
|
- lib/safe_memoize/public_metrics_methods.rb
|
|
68
|
+
- lib/safe_memoize/rails.rb
|
|
69
|
+
- lib/safe_memoize/rails/middleware.rb
|
|
70
|
+
- lib/safe_memoize/rails/request_scoped.rb
|
|
62
71
|
- lib/safe_memoize/release_tooling.rb
|
|
63
72
|
- lib/safe_memoize/version.rb
|
|
64
73
|
- sig/safe_memoize.rbs
|