diff options
author | Dante Catalfamo | 2023-04-28 01:18:06 -0400 |
---|---|---|
committer | Dante Catalfamo | 2023-04-28 01:18:06 -0400 |
commit | a648d55e060dea59540a50c5ba7464f2197acf3a (patch) | |
tree | 149ca9f4fddee36a5be3247884db06be5bba561f | |
parent | 6904c437a208e625dd1500ae50a218eb51be5188 (diff) | |
download | blog-a648d55e060dea59540a50c5ba7464f2197acf3a.tar.gz blog-a648d55e060dea59540a50c5ba7464f2197acf3a.tar.bz2 blog-a648d55e060dea59540a50c5ba7464f2197acf3a.zip |
rails-test-cache: Language
-rw-r--r-- | content/posts/testing-rails-cache/index.org | 12 |
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 |