Code
memcached
# Invalidate ALL keys immediately (logically)
flush_all
# OK
# Delayed invalidation (after N seconds)
flush_all 60
# OK
# keys still readable for 60s, then ignored
# Verify
get user:42
# END <- returns nothing
# Python
from pymemcache.client.base import Client
c = Client(("localhost", 11211))
c.flush_all()
# WARNING: flush_all is global — affects ALL keys, not a namespace.
# There is no "delete pattern *" in Memcached.
# Namespacing trick: include a version prefix in keys, bump version to "flush"
# user:v3:42 <- bump v3 -> v4 to logically invalidate all user:* keys
# (old keys expire naturally or get evicted)
# Also: flush_all does NOT free memory immediately — items are
# removed lazily as they're requested or evicted. Restart the
# daemon to actually reclaim RSS.