Skip to content

Instantly share code, notes, and snippets.

@EppO
Created October 19, 2009 13:12
Show Gist options
  • Save EppO/213348 to your computer and use it in GitHub Desktop.
Save EppO/213348 to your computer and use it in GitHub Desktop.
trying to cache sequel models in memcached
$ sequel postgres://mylogin:mypasswd@localhost/bddtest
Your database is stored in DB...
>> require 'memcache'
=> true
>> MemCache
=> MemCache
>> MemCache::VERSION
=> "1.5.0.1"
>> CACHE = MemCache.new("localhost")
=> MemCache: 1 servers, 1 buckets, ns: nil, ro: false
>> require 'lib/post'
=> true
>> p = Post.first
=> #<Post @values={:type=>3, :comments_count=>1, :title=>"toto", :body=>"test", :added=>nil, :id=>3}>
>> p[:type] = 0
=> 0
>> p
=> #<Post @values={:type=>0, :comments_count=>1, :title=>"toto", :body=>"test", :added=>nil, :id=>3}>
>> CACHE.set(p[:id], p)
=> "STORED\r\n"
>> CACHE.get(p.id)
=> #<Post @values={:type=>0, :comments_count=>1, :title=>"toto", :body=>"test", :added=>nil, :id=>3}>
>> p.save
=> #<Post @values={:type=>0, :comments_count=>1, :title=>"toto", :body=>"test", :added=>nil, :id=>3}>
>> CACHE.set(p[:id], p)
TypeError: can't dump hash with default proc
from /usr/lib/ruby/gems/1.8/gems/fiveruns-memcache-client-1.5.0.5/lib/memcache.rb:258:in `dump'
from /usr/lib/ruby/gems/1.8/gems/fiveruns-memcache-client-1.5.0.5/lib/memcache.rb:258:in `set'
from /usr/lib/ruby/gems/1.8/gems/fiveruns-memcache-client-1.5.0.5/lib/memcache.rb:596:in `with_server'
from /usr/lib/ruby/gems/1.8/gems/fiveruns-memcache-client-1.5.0.5/lib/memcache.rb:256:in `set'
from (irb):13
>>
Your database is stored in DB...
>> require 'memcached'
=> true
>> Memcached::VERSION
=> "0.17.3"
>> CACHE = Memcached.new("localhost")
=> #<Memcached:0xb788365c @struct=#<Rlibmemcached::MemcachedSt:0xb7883620>, not_found#<Memcached::NotFound: Memcached::NotFound, @default_ttl=604800, @options={:support_cas=>false, :prefix_key=>nil, :default_weight=>8, :rcv_timeout=>0.25, :hash_with_prefix_key=>true, :cache_lookups=>true, :server_failure_limit=>2, :no_block=>false, :distribution=>:consistent_ketama, :timeout=>0.25, :binary_protocol=>false, :poll_timeout=>0.25, :sort_hosts=>false, :use_udp=>false, :hash=>:fnv1_32, :ketama_weighted=>true, :show_backtraces=>false, :tcp_nodelay=>false, :connect_timeout=>2, :default_ttl=>604800, :auto_eject_hosts=>true, :buffer_requests=>false, :retry_timeout=>30, :verify_key=>true}, not_stored#<Memcached::NotStored: Memcached::NotStored, @servers=["localhost:11211:8"]>
>> require 'lib/post'
=> true
>> p = Post.first
=> #<Post @values={:type=>3, :comments_count=>1, :title=>"toto", :body=>"test", :added=>nil, :id=>3}>
>> p[:type] = 0
=> 0
>> p
=> #<Post @values={:type=>0, :comments_count=>1, :title=>"toto", :body=>"test", :added=>nil, :id=>3}>
>> CACHE.set(p[:id], p)
=> nil
>> CACHE.get(p.id)
=> #<Post @values={:type=>0, :comments_count=>1, :title=>"toto", :body=>"test", :added=>nil, :id=>3}>
>> p.save
=> #<Post @values={:type=>0, :comments_count=>1, :title=>"toto", :body=>"test", :added=>nil, :id=>3}>
>> CACHE.set(p[:id], p)
TypeError: can't dump hash with default proc
from /usr/lib/ruby/gems/1.8/gems/memcached-0.17.3/lib/memcached/memcached.rb:223:in `dump'
from /usr/lib/ruby/gems/1.8/gems/memcached-0.17.3/lib/memcached/memcached.rb:223:in `set'
from (irb):13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment