setup_memcache defines CACHE even if disabled:true
-
Chris Wanstrath
- State changed from new to open
- Assigned user set to Chris Wanstrath
- Milestone set to acts_as_cached 2
No good reason for this. I'll see if I can cleanly do what you're suggesting, though it might not be today. If you can send a patch with all the tests still passing that would speed things up on my end.
-
Oliver Nicholas
I mean, I'm open to other suggestions, but I don't think it makes sense for cache_fu to clobber the ability for external code to determine if memcached is supposed to be used. That's just too assumptive for my tastes.
If CACHE must be set, then the best other option I can think of is to wrap the CACHE.servers= line with the conditional. that way, CACHE.active? will return false since no servers will be added if config[:disabled].
as for testing it...none of my cache_fu tests will run. they all die on trying to include active_support. i have rails frozen but no gem installed...do i need it?
-
Oliver Nicholas
okay so installing rails as a gem solved the test problem. here's my svn diff, but note that the tests don't pass for me even without making my changes - "should be able to re-raise errors" dies because it can't find a namespace for the CACHE object. I don't know how it works though, cause I don't use a localhost memcached even for development. is that a requirement? seems like it should be mocked out for that purpose.
also, a point of interest: my revision number for the svn diff are wonky cause i have the plugin installed via piston, so it's a rev from my app's repo, not yours.
also, it's more or less my job to make this work, so let me know if you want some assistance.
Index: lib/acts_as_cached/config.rb
===================================================================
--- lib/acts_as_cached/config.rb (revision 7934)
+++ lib/acts_as_cached/config.rb (working copy)
@@ -43,19 +43,19 @@
def setup_memcache(config)
config[:namespace] << "-#{RAILS_ENV}"
+ silence_warnings do
+ Object.const_set :CACHE, MemCache.new(config)
+ end
+
unless config[:disabled]
- silence_warnings do
- Object.const_set :CACHE, MemCache.new(config)
- end
-
CACHE.servers = Array(config.delete(:servers))
setup_session_store if config[:sessions]
setup_fragment_store! if config[:fragments]
setup_fast_hash! if config[:fast_hash]
-
- CACHE
end
+
+ CACHE
end
def setup_session_store
-
Oliver Nicholas
no
, huh?
-
Oliver Nicholas
christ i guess there is a <pre>.
Index: lib/acts_as_cached/config.rb
===================================================================
--- lib/acts_as_cached/config.rb (revision 7934)
+++ lib/acts_as_cached/config.rb (working copy)
@@ -43,19 +43,19 @@
def setup_memcache(config)
config[:namespace] << "-#{RAILS_ENV}"
+ silence_warnings do
+ Object.const_set :CACHE, MemCache.new(config)
+ end
+
unless config[:disabled]
- silence_warnings do
- Object.const_set :CACHE, MemCache.new(config)
- end
-
CACHE.servers = Array(config.delete(:servers))
setup_session_store if config[:sessions]
setup_fragment_store! if config[:fragments]
setup_fast_hash! if config[:fast_hash]
-
- CACHE
end
+
+ CACHE
end
def setup_session_store
-
Chris Wanstrath
Alright, I'll try and get this in. http://pastie.caboo.se/ would really work better, I can't cleanly copy and paste this guy easily.
-
Chris Wanstrath
- State changed from open to hold
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.