summaryrefslogtreecommitdiffstats
path: root/content/posts/testing-rails-cache/index.org
diff options
context:
space:
mode:
authorDante Catalfamo2023-04-28 01:18:06 -0400
committerDante Catalfamo2023-04-28 01:18:06 -0400
commita648d55e060dea59540a50c5ba7464f2197acf3a (patch)
tree149ca9f4fddee36a5be3247884db06be5bba561f /content/posts/testing-rails-cache/index.org
parent6904c437a208e625dd1500ae50a218eb51be5188 (diff)
downloadblog-a648d55e060dea59540a50c5ba7464f2197acf3a.tar.gz
blog-a648d55e060dea59540a50c5ba7464f2197acf3a.tar.bz2
blog-a648d55e060dea59540a50c5ba7464f2197acf3a.zip
rails-test-cache: Language
Diffstat (limited to 'content/posts/testing-rails-cache/index.org')
-rw-r--r--content/posts/testing-rails-cache/index.org12
1 files changed, 7 insertions, 5 deletions
diff --git a/content/posts/testing-rails-cache/index.org b/content/posts/testing-rails-cache/index.org
index 397eae4..9c98f7f 100644
--- a/content/posts/testing-rails-cache/index.org
+++ b/content/posts/testing-rails-cache/index.org
@@ -11,11 +11,13 @@ If you're in the default testing environment your rails cache is
[[https://api.rubyonrails.org/classes/ActiveSupport/Cache/NullStore.html][=ActiveSupport::Cache::NullStore=]] which will always succeed but it
doesn't actually store or return anything.
-There's an almost completely undocumented function called
-=with_local_cache= that gets implemented on =NullStore= that lets
-you run a block with a =MemoryStore= instead of a =NullStore=. This
-happens because it =prepends= the
-[[https://api.rubyonrails.org/classes/ActiveSupport/Cache/Strategy/LocalCache.html][=ActiveSupport::Cache::Strategy::LocalCache=]] class.
+There's an almost completely undocumented method called
+=with_local_cache= on =NullStore= that lets you run a block with a
+=MemoryStore= instead of a =NullStore= for the duration of the block.
+This happens because it =prepends= the
+[[https://api.rubyonrails.org/classes/ActiveSupport/Cache/Strategy/LocalCache.html][=ActiveSupport::Cache::Strategy::LocalCache=]] class. This lets you test
+one or two things that require caching without enabling it on all
+tests and slowing everything down.
#+begin_src ruby
Rails.cache.class.name