Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Show how to implement custom `#freeze`.
  • Loading branch information
ioquatix committed Jun 27, 2019
1 parent 10d6ec9 commit be65b4d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ class CacheEverythingForever
@cache_all_the_things = Concurrent::Map.new
end

def freeze
return self if frozen?

# Don't freeze @cache_all_the_things
@app.freeze

super
end

def call(env)
# Use the thread-safe `Concurrent::Map` to fetch the value or store it if it doesn't exist already.
@cache_all_the_things.fetch_or_store(env[Rack::PATH_INFO]) do
Expand Down

0 comments on commit be65b4d

Please sign in to comment.