Skip to content

Commit

Permalink
Merge pull request #12 from Kaligo/bug/set-cache-expiry
Browse files Browse the repository at this point in the history
Set 1 day expiration time for idempotent response
  • Loading branch information
hieuk09 authored Feb 4, 2025
2 parents b77520b + dd70dc5 commit c7aa848
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## [Change Log]

## [0.1.5] - 2025-02-04

- Set correct expiration time for idempotency cache

## [0.1.4] - 2025-01-14

- Support metrics logging via StatsdListener
Expand All @@ -19,4 +23,3 @@
## [0.1.0] - 2024-11-13

- Initial release

2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
idempotency (0.1.4)
idempotency (0.1.5)
base64
dry-configurable
dry-monitor
Expand Down
2 changes: 1 addition & 1 deletion lib/idempotency/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def set(fingerprint, response_status, response_headers, response_body)
key = response_cache_key(fingerprint)

with_redis do |r|
r.set(key, serialize(response_status, response_headers, response_body))
r.set(key, serialize(response_status, response_headers, response_body), ex: DEFAULT_CACHE_EXPIRY)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/idempotency/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class Idempotency
VERSION = '0.1.4'
VERSION = '0.1.5'
end
3 changes: 2 additions & 1 deletion spec/idempotency/cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@
let(:response_headers) { { 'header' => 'valuee' } }

it 'sets data in cache correctly' do
is_expected.to eq('OK')
expect(subject).to eq('OK')
expect(cache.get(fingerprint)).to eq([response_status, response_body, response_headers])
expect(mock_redis.ttl("idempotency:cached_response:#{fingerprint}")).to eq(86_400)
end
end

Expand Down

0 comments on commit c7aa848

Please sign in to comment.