defconomicron / dalli-store-extensions

dalli-store-extensions is based on jkassemi's memcache-store-extensions gem @ https://github.com/jkassemi/memcache-store-extensions
http://tweekedideas.com/
20 stars 25 forks source link

Exception on Ruby 1.9.3 #1

Open nd2s opened 12 years ago

nd2s commented 12 years ago

On Ruby 1.9.3 got following exception: NoMethodError (undefined method `value' for #String:0x00000004326848)

I don't know why exactly but this seems to fix it (I guess it will break it for Ruby 1.8): https://github.com/mqt/dalli-store-extensions/commit/dd0b5ee7779600e8ff7e63491e23a5b51c647f6d

pierrevalade commented 12 years ago

Got the same error.

jjb commented 12 years ago

I'm getting this too, and @mqt's change fixes it for me

ghost commented 12 years ago

I too have same error with ruby 1.9.2

aehven commented 11 years ago

I get a similar error with ruby 1.9.2:

undefined method `value' for "---\n- views/my_key\n":String

and it goes away when I clear the cache. Can someone explain how I get @mqt's fix? Do I have to pull the gem from somewhere else or download the code into the vendors dir and change it there?

nd2s commented 11 years ago

You have to use the gem from my repo. But the fix is old and I don't really know what I did there. Wouldn't use that code on a production system..

I switched from memcached to redis then, which supports listing of keys and works much nicer. (I got some other issues with memcached and keys not being invalidated).

aehven commented 11 years ago

Oh. Thanks for the advice, I'll look into Redis.

Thanks,

On Dec 21, 2012, at 5:15 PM, mqt notifications@github.com wrote:

You have to use the gem from my repo. But the fix is old and I don't really know what I did there. Wouldn't use that code on a production system..

I switched from memcached to redis then, which supports listing of keys and works much nicer. (I got some other issues with memcached and keys not being invalidated).

— Reply to this email directly or view it on GitHub.

aehven commented 11 years ago

Thanks again, @mqt, for the advice. I'm using Redis now and it seems to work.

For anyone else running into this, the use of Redis needs to be tweaked when using it as the cache_store. First of all, you must load the 'redis-rails' gem as well as the 'redis' gem. Then you must deal with the fact that Redis matches keys by a simplified wildcard notation rather than ruby Regexp. I found the details here:

http://dev.mensfeld.pl/2012/06/rails-3-2-redis-store-views-caching-and-expire_fragment-with-regexp/

But in my case I preferred to just fix my sweeper so that it uses redis wild-cards instead of adding the code shown in the link above to convert Regexp to redis wild-card keys. So all I did was fix the fragment string designations in my sweeper to use wildcards and add this to my redis.rb initializer to force redis to delete all matching keys when given a string:

module ActiveSupport
  module Cache
    class RedisStore < Store
      def delete(key, options)
        delete_matched(key, options)
      end
    end
  end
end