Skip to content

Commit

Permalink
Fix ruby 3 keyword argument split compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanahsmith committed Jan 15, 2021
1 parent 71ac900 commit cac2055
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
gemfile: "Gemfile.latest-release"
rubocop: true
- name: 'Rails edge'
ruby: 2.7
ruby: 3.0
gemfile: "Gemfile.rails-edge"
edge: true

Expand Down
2 changes: 1 addition & 1 deletion dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ up:
- [email protected]:
or: [[email protected]]
conflicts: [mysql-connector-c, mysql, mysql-client]
- ruby: 2.6.5
- ruby: 2.7.2
- railgun
- bundler

Expand Down
4 changes: 2 additions & 2 deletions lib/identity_cache/cache_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def fetch_with_fill_lock(key, fill_lock_duration, lock_wait_tries)
if !fill_with_lock(key, data, lock, expiration_options) && !using_fallback_key
# fallback to storing data in the fallback key so it is available to clients waiting on the lock
expiration_options = fallback_key_expiration_options(fill_lock_duration)
@cache_backend.write(lock_fill_fallback_key(key, lock), data, **expiration_options)
@cache_backend.write(lock_fill_fallback_key(key, lock), data, expiration_options)
end
return data
else
Expand Down Expand Up @@ -296,7 +296,7 @@ def add_multi(keys)
result.each { |k, v| add(k, v) }
end

def add(key, value, **expiration_options)
def add(key, value, expiration_options = EMPTY_HASH)
return false unless IdentityCache.should_fill_cache?
@cache_backend.write(key, value, { unless_exist: true, **expiration_options })
end
Expand Down
2 changes: 1 addition & 1 deletion lib/identity_cache/memoized_cache_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def fetch(key, cache_fetcher_options = {})

value = fetch_memoized(key) do
memo_misses = 1
@cache_fetcher.fetch(key, cache_fetcher_options) do
@cache_fetcher.fetch(key, **cache_fetcher_options) do
cache_misses = 1
instrument_duration(payload, :resolve_miss_time) do
yield
Expand Down
4 changes: 2 additions & 2 deletions test/fetch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_fetch_cache_hit_publishes_hydration_notification
end

def test_fetch_cache_hit_publishes_cache_notification
IdentityCache.cache.cache_fetcher.expects(:fetch).with(@blob_key, {}).returns(@cached_value)
IdentityCache.cache.cache_fetcher.expects(:fetch).with(@blob_key).returns(@cached_value)
expected = { memoizing: false, resolve_miss_time: 0, memo_hits: 0, cache_hits: 1, cache_misses: 0 }

events = 0
Expand All @@ -59,7 +59,7 @@ def test_fetch_cache_hit_publishes_cache_notification

def test_fetch_memoized_hit_publishes_cache_notification
subscriber = nil
IdentityCache.cache.cache_fetcher.expects(:fetch).with(@blob_key, {}).returns(@cached_value)
IdentityCache.cache.cache_fetcher.expects(:fetch).with(@blob_key).returns(@cached_value)
expected = { memoizing: true, resolve_miss_time: 0, memo_hits: 1, cache_hits: 0, cache_misses: 0 }

IdentityCache.cache.with_memoization do
Expand Down
2 changes: 1 addition & 1 deletion test/memoized_cache_proxy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_fetch_should_short_circuit_on_falsy_memoized_values
end

def test_fetch_should_try_memcached_on_not_memoized_values
fetcher.expects(:fetch).with('foo', {}).returns('bar')
fetcher.expects(:fetch).with('foo').returns('bar')

IdentityCache.cache.with_memoization do
assert_equal('bar', IdentityCache.cache.fetch('foo'))
Expand Down

0 comments on commit cac2055

Please sign in to comment.