Skip to content

Commit

Permalink
Check if rpsec concurrency changes do a thing
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgan Brown committed Jul 9, 2024
1 parent db65a30 commit 36f90d1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/cached_resource/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class Configuration < OpenStruct
# prefix for log messages
LOGGER_PREFIX = "[cached_resource]"

# "Internal" variable to represent enabling concurrency
# so that we know when its value changes.
attr_reader :concurrent_write

# Initialize a Configuration with the given options, overriding any
Expand Down
7 changes: 7 additions & 0 deletions spec/cached_resource/caching_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,14 @@ class NotTheThing < ActiveResource::Base

it "should cache a response asynchronusly when on" do
Thing.cached_resource.concurrent_write = true
expect(Concurrent::Promise).to receive(:execute).and_wrap_original do |original_method, *args, &block|
original_method.call(*args, &block)
end
result = Thing.find(5)
# sleep 1
# expect(Concurrent::Promise).to receive(:execute)
# Concurrent::Promise.execute

read_from_cache("thing/5").should == nil
loops = 0
begin
Expand Down

0 comments on commit 36f90d1

Please sign in to comment.