What’s the memcached server

I agree with most things @phihag has answered but I must clarify some things. Memcached stores data according to a key (phihag called it an id, not to be confused with database ids). Data can be of various sizes so you can store small bits (like 1 record pulled from the database) or you can … Read more

Memcache maximum key expiration time

You can set key expiration to a date, by supplying a Unix timestamp instead of a number of days. This date can be more than 30 days in the future: Expiration times are specified in unsigned integer seconds. They can be set from 0, meaning “never expire”, to 30 days (60*60*24*30). Any time higher than … Read more

How to set up memcached to use unix socket?

You may find that just setting the socket path doesn’t work. Memcached drops privileges before it creates its socket, though after it’s written its PID. It’s common to put the socket in /var/run (e.g. as mysql does), but only root can write there, so create /var/run/memcached and chown it to nobody, then set /var/run/memcached/memcached.sock as … Read more

Memcache basic configuration

You did not tell us about your OS/distro. Also, you did not tell us how you installed memcached. Usually, you will get a sample config file under /etc/ when you install memcached using apt-get under debian-based systems and rpm or yum under redhat, fedora or centos. If you installed it from source, you may not … Read more

Failed to connect to memcache host !

# memcached -u memcached -d -m 30 -l 127.0.0.1 -p 11211 You’ll notice there is “-l 127.0.0.1” in your command line. This tells memcached to only listen on the lo interface. If you want to access it from a remote machine, you need to remove this part of the command line.

Add vs Set in Memcached

You’ve pretty much got the answer to your first question already: the intent of ADD is to only work when a key doesn’t already exist, while SET is there to update the value, regardless of whether it already exists. If you’re familiar with SQL, it’s (roughly) like the difference between INSERT queries (ADD) and UPDATE … Read more