This project is archived and is in readonly mode.
[PATCH] Add a NullStore to ActiveSupport::Cache
-
Doug Cole
I just spend 30 minutes trying to figure this out too, when starting to use Rails.cache. If no one is working on this I'll write a patch - looks pretty simple.
-
CancelProfileIsBroken
- Tag set to bugmash
-
John Pignata
Since the Rails.cache functionality exists in ActiveSupport and not ActionController, I propose a new configuration setting of config.active_support.perform_caching= with a default of true.
The patch adds this behavior to Active Support and also modifies the stores to honor the setting. exists? and read will return false and nil respectively when perform caching is set to false. Feedback?
-
John Pignata
- Tag changed from bugmash to bugmash, patch
- Title changed from Perform caching=false should not perform caching to [PATCH] Perform caching=false should not perform caching
-
Derander
+1, this seems like an appropriate change. Shouldn't break backwards compatibility.
Applies cleanly to latest master & tests pass.
-
David Reese
- Title changed from [PATCH] Perform caching=false should not perform caching to [PATCH] ActiveSupport should have a "perform_caching=false" setting
Ok, now I get that when you say "action_controller.perform_caching = false", you're turning off page, action, and fragment caching, not all caching that happens in your controllers. Somehow that was not clear to me.
But, +1 on John's patch -- there should be some way to also turn off ActiveSupport caching, and the patch does that ably.
One thing I would change for cleanliness -- I'd set @@perform_caching=true first, which seems to be common practice in Rails. The section where @@perform_caching is checked for nil seemed a little opaque:
{mkd-extraction-e508fd6e2a88aa82336506488855005a}I'd add this, and then you don't need to check for nil in #cache_configured?, just return perform_caching:
{mkd-extraction-d4304b7970b636c816dabf43df1f88e0}
+ @@perform_caching = trueI tried to make a new patch but it seemed to add my patch onto John's patch. If there's a cleaner way to to that someone should probably go ahead and do it.
-
John Pignata
- Tag changed from bugmash, patch to activesupport, bugmash, cache, patch
Good feedback - thanks, David. Attached is a patch with your feedback that will apply to master.
-
John Pignata
For good measure, here's a patch for 2.3 stable if it's desired to get this in prior to 3.0
-
John Pignata
- Title changed from [PATCH] ActiveSupport should have a "perform_caching=false" setting to [PATCH] Add a NullStore to ActiveSupport::Cache
- Assigned user set to Michael Koziarski
Talked to nzkoz who was of the opinion that this patch should instead be a null store that users could implement for edge cases in debugging and testing. This makes sense and is more flexible than a configuration setting. Attached is a patch to add a null store to master.
-
Elad Meidar
+1 verified and nailed :) Looks like it's a well respected behavior, latest patch applies cleanly on latest master.
-
David Reese
What about "BlackholeStore" instead? It's so much more poetic. (There's some reason we're not python developers, right?)
-
CancelProfileIsBroken
- Tag changed from activesupport, bugmash, cache, patch to activesupport, bugmash, bugmash-review, cache, patch
-
John Pignata
Any additional feedback on this feature?
-
Rizwan Reza
- Tag changed from activesupport, bugmash, bugmash-review, cache, patch to activesupport, bugmash-review, cache, patch
-
Rizwan Reza
- Tag changed from activesupport, bugmash-review, cache, patch to activesupport, bugmash, cache, patch
-
Simon Jefford
- Tag changed from activesupport, bugmash, cache, patch to activesupport, bugmash, bugmash-review, cache, patch
I've rebased the above patch, cleaned up some whitespace issues and updated it slightly so overrides the correct methods (they seem to have changed slightly from when this patch was submitted).
The original authorship has been retained in the patch.
+1 verified
-
Simon Jefford
Updated patch - more test coverage + remove unnecessary override
-
Rizwan Reza
- Tag changed from activesupport, bugmash, bugmash-review, cache, patch to activesupport, bugmash, cache, patch
- State changed from new to open
We still need some +1s here.
-
Peter Marklund
I like this patch as it enabled global disabling of the cache. To me it would make sense to have an enabled attribute on the Rails.cache object, something I achieved with a monkey patch:
http://developer.newsdesk.se/2010/05/04/enablingdisabling-the-rails...
-
Santiago Pastorino
- Importance changed from to
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale
