philiprehberger-cache_kit 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75ef7dbba5f362a4a3370f2e389421bca6aeb29288b42060c9f13a497070a9ba
4
- data.tar.gz: caf151b0c9641bcddce86d10521b21b7746c99d2200bce020dbec3402edbdee5
3
+ metadata.gz: 5687a486d3607bcd2bd3dff4601ac6cb1d477896a99331ed05d86367ba346585
4
+ data.tar.gz: 74641aea2440ee38c179bb4fcac6bbcab03745829bf7a516e22e642095a25e85
5
5
  SHA512:
6
- metadata.gz: 2d6e3b0e24792d38afb21da30ccdb2b453a5e68ee96ccdab24115ab3bf67158f6ee139ed1e95748ea0a31f0a23df055d8352549502af3949cf315396aacb0465
7
- data.tar.gz: 5274211ebd71bac978295d49e35e80ecade8ed6696a90193761b89d2994b97c9e634858b5021d2a36b231fb34b4ee2a84f265583364793fd309be83f941a1561
6
+ metadata.gz: fe418c1c4adf7741d10e9ba7845d6dce658e633cc3204112388b46db9a142fc66c41993d28fa323125a3778e5775360564f27f8157689920e1e7dfd5607e5818
7
+ data.tar.gz: 33fe25461335ba600dcf7ac159e6b00e3c00d8d702e3f213ad01969db6e1753728682349f5d948760a3572cd247de630f069c11a12f6f85f4408f63e0869f1a7
data/CHANGELOG.md CHANGED
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.5.0] - 2026-04-04
11
+
12
+ ### Changed
13
+ - `#get_many` now accepts splat args (`get_many(*keys)`) and skips misses, returning only found entries
14
+
15
+ ### Added
16
+ - `gem-version` field to bug report issue template
17
+ - `Alternatives considered` textarea to feature request issue template
18
+
10
19
  ## [0.4.0] - 2026-04-01
11
20
 
12
21
  ### Added
data/README.md CHANGED
@@ -83,14 +83,14 @@ cache.prune
83
83
 
84
84
  ### Batch Get
85
85
 
86
- Retrieve multiple keys in a single lock acquisition. Returns a hash mapping each key to its value (or nil if missing/expired).
86
+ Retrieve multiple keys in a single lock acquisition. Returns a hash of found entries only, skipping misses.
87
87
 
88
88
  ```ruby
89
89
  cache.set("a", 1)
90
90
  cache.set("b", 2)
91
91
 
92
- cache.get_many(["a", "b", "missing"])
93
- # => { "a" => 1, "b" => 2, "missing" => nil }
92
+ cache.get_many("a", "b", "missing")
93
+ # => { "a" => 1, "b" => 2 }
94
94
  ```
95
95
 
96
96
  ### Bulk Set
@@ -203,7 +203,7 @@ new_cache.restore(Marshal.load(File.read("cache.bin")))
203
203
  | `Store#stats(tag: name)` | Returns `{ hits:, misses:, evictions: }` for a tag |
204
204
  | `Store#prune` | Remove all expired entries, returns count removed |
205
205
  | `Store#on_evict { \|key, value\| }` | Register eviction callback |
206
- | `Store#get_many(keys)` | Batch get, returns `{ key => value }` hash |
206
+ | `Store#get_many(*keys)` | Batch get, returns `{ key => value }` for found entries |
207
207
  | `#set_many(hash, ttl:, tags:)` | Bulk set multiple entries |
208
208
  | `#compact` | Prune expired entries, return eviction count |
209
209
  | `#refresh(key, ttl:)` | Reset TTL without changing value |
@@ -5,14 +5,19 @@ module Philiprehberger
5
5
  # Batch operations for Store.
6
6
  module Batch
7
7
  # Retrieve multiple keys in a single lock acquisition.
8
+ # Returns only found (non-nil, non-expired) entries, skipping misses.
8
9
  #
9
10
  # @param keys [Array<String>] cache keys to retrieve
10
- # @return [Hash] key => value pairs (missing/expired keys map to nil)
11
- def get_many(keys)
11
+ # @return [Hash] key => value pairs for found entries only
12
+ def get_many(*keys)
13
+ keys = keys.flatten
12
14
  @mutex.synchronize do
13
- keys.to_h do |key|
14
- [key, fetch_entry(key)]
15
+ result = {}
16
+ keys.each do |key|
17
+ value = fetch_entry(key)
18
+ result[key] = value unless value.nil?
15
19
  end
20
+ result
16
21
  end
17
22
  end
18
23
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Philiprehberger
4
4
  module CacheKit
5
- VERSION = '0.4.0'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: philiprehberger-cache_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Rehberger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-01 00:00:00.000000000 Z
11
+ date: 2026-04-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A lightweight, thread-safe in-memory LRU cache with TTL expiration and
14
14
  tag-based bulk invalidation for Ruby applications.