V
V
Viktor Vsk2014-06-05 10:55:11
Ruby on Rails
Viktor Vsk, 2014-06-05 10:55:11

Rails memcache. How to properly set "limit_maxbytes"?

memcahed -I 64M

Rails.cache.stats
=> {"127.0.0.1:11211"=>
  {"pid"=>"5790",
   "uptime"=>"248",
   "time"=>"1401954461",
   "version"=>"1.4.14 (Ubuntu)",
   "libevent"=>"2.0.21-stable",
   "pointer_size"=>"32",
   "rusage_user"=>"0.228000",
   "rusage_system"=>"0.220000",
   "curr_connections"=>"11",
   "total_connections"=>"13",
   "connection_structures"=>"12",
   "reserved_fds"=>"20",
   "cmd_get"=>"19",
   "cmd_set"=>"15",
   "cmd_flush"=>"0",
   "cmd_touch"=>"0",
   "get_hits"=>"5",
   "get_misses"=>"14",
   "delete_misses"=>"1",
   "delete_hits"=>"0",
   "incr_misses"=>"0",
   "incr_hits"=>"0",
   "decr_misses"=>"0",
   "decr_hits"=>"0",
   "cas_misses"=>"0",
   "cas_hits"=>"0",
   "cas_badval"=>"0",
   "touch_hits"=>"0",
   "touch_misses"=>"0",
   "auth_cmds"=>"0",
   "auth_errors"=>"0",
   "bytes_read"=>"24141",
   "bytes_written"=>"1704",
   "limit_maxbytes"=>"67108864",
   "accepting_conns"=>"1",
   "listen_disabled_num"=>"0",
   "threads"=>"4",
   "conn_yields"=>"0",
   "hash_power_level"=>"16",
   "hash_bytes"=>"262144",
   "hash_is_expanding"=>"0",
   "expired_unfetched"=>"0",
   "evicted_unfetched"=>"0",
   "bytes"=>"23203",
   "curr_items"=>"14",
   "total_items"=>"15",
   "evictions"=>"0",
   "reclaimed"=>"0"}}

It can be seen that limit_maxbytes = 64 megabytes.
But I can't write an object of 4 megabytes in size. Neither in the console nor on the server (restarted both)
Via the web:
Value for Test over max size: 1048576 <= 4116715
In the console it just writes false.
I'm actually calling it like this:
Rails.cache.fetch('Test'){ Spree::Product.all }.count.to_s

Rails 3.2
Ruby 2.1.1
Dalli
Memcachier

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimitriy, 2014-06-05
@viktorvsk

memcahed -m 64M -I 10M

Rails.cache.fetch('10mb'){ 'x' * 10.megabytes }.size
Cache read: 10mb
Cache generate: 10mb
Cache write: 10mb
Value for 10mb over max size: 10485760 <= 10485773

Rails.cache.fetch('9mb'){ 'x' * 9.megabytes }.size
Cache read: 9mb
Cache fetch_hit: 9mb

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question