From b23c30426d32cb086bd028c7ce3d097adebfec8e Mon Sep 17 00:00:00 2001 From: Daniel Westendorf Date: Wed, 18 Sep 2024 20:56:04 -0600 Subject: [PATCH] Update readme to mention the reset! method --- README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 142d939..ed74b1d 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,25 @@ end TTLMemoizeable.disable! ``` -3. Conditionally TTL memoize the method based on test environment or some other condition. +3. Reset ttl memoization values before/after your test runs. + +```ruby +# RSpec +RSpec.configure do |config| + config.around { TTLMemoizeable.reset!; _1.run; TTLMemoizeable.reset! } +end + +# minitest +def setup + TTLMemoizeable.reset! +end + +def teardown + TTLMemoizeable.reset! +end +``` + +4. Conditionally TTL memoize the method based on test environment or some other condition. ```ruby def config JSON.parse($redis.get("some_big_json_string"))