There is the command in memcached protocol named "flush_all". It assumed to purge (invalidate) all stored items. But it does not. Reproducible: Always Steps to Reproduce: 1. run memcached 1.2.5 2. telnet 0 11211 3. type "stats", check "curr_items" 4. type "flush_all" 5. type "stats", check "curr_items" Actual Results: shark3 ~ # telnet 0 11211 Trying 0.0.0.0... Connected to 0. Escape character is '^]'. stats STAT pid 29308 STAT uptime 1211 STAT time 1223910499 STAT version 1.2.5 STAT pointer_size 64 STAT rusage_user 0.360000 STAT rusage_system 0.610000 STAT curr_items 3342 STAT total_items 3360 STAT bytes 279869 STAT curr_connections 30 STAT total_connections 792 STAT connection_structures 38 STAT cmd_get 5102 STAT cmd_set 3343 STAT get_hits 1787 STAT get_misses 3315 STAT evictions 0 STAT bytes_read 374320 STAT bytes_written 154951 STAT limit_maxbytes 268435456 STAT threads 4 END flush_all OK stats STAT pid 29308 STAT uptime 1255 STAT time 1223910543 STAT version 1.2.5 STAT pointer_size 64 STAT rusage_user 0.360000 STAT rusage_system 0.610000 STAT curr_items 3447 STAT total_items 3483 STAT bytes 288597 STAT curr_connections 31 STAT total_connections 817 STAT connection_structures 38 STAT cmd_get 5324 STAT cmd_set 3464 STAT get_hits 1888 STAT get_misses 3436 STAT evictions 0 STAT bytes_read 389497 STAT bytes_written 162511 STAT limit_maxbytes 268435456 STAT threads 4 END Expected Results: items should be purged from memcache kernel: 2.6.25-hardened-r7
You're wrong. You have failed to understand the cache eviction policy for memcached. I cite from the documentation: ======= "flush_all" is a command with an optional numeric argument. It always succeeds, and the server sends "OK\r\n" in response (unless "noreply" is given as the last parameter). Its effect is to invalidate all existing items immediately (by default) or after the expiration specified. After invalidation none of the items will be returned in response to a retrieval command (unless it's stored again under the same key *after* flush_all has invalidated the items). flush_all doesn't actually free all the memory taken up by existing items; that will happen gradually as new items are stored. The most precise definition of what flush_all does is the following: it causes all items whose update time is earlier than the time at which flush_all was set to be executed to be ignored for retrieval purposes. ======= Easy testcase: ===== set a 0 60 1\r\n 1\r\n get a\r\n incr a\r\n get a\r\n flush_all\r\n get a\r\n ===== The last "get a" will return nothing.