Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual Excerpts from this Manual Verifying the InnoDB and memcached Setup

Now that everything is set up, you can experiment with the InnoDB and memcached combination:

Here is an example using the Unix, Linux, or OS X command shell:

# Point memcached-related commands at the memcached attached to the mysqld process.
# Store the contents of a modestly sized text file in memcached, with the data passed
# to MySQL and stored in a table. The key is the basename of the file, 'mime.types'.
memcp /etc/apache2/mime.types
# Retrieve the data we just stored, from the memory cache.
memcat mime.types

Here is an example using telnet to send memcached commands and receive results through the ASCII protocol:

telnet 11211
set a11 10 0 9
get a11
VALUE a11 0 9

To prove that all the same data has been stored in MySQL, connect to the MySQL server and issue:

mysql> select * from test.demo_test;

Now, shut down the MySQL server, which also shuts off the integrated memcached server. Further attempts to access the memcached data now fail with a connection error. Normally, the memcached data would disappear at this point, and you would write application logic to load the data back into memory when memcached was restarted. But the MySQL / memcached integration automates this process:

  • Restart the MySQL server.

  • Now any memcat commands or get operations once again return the key/value pairs you stored in the earlier memcached session. When a key is requested and the associated value is not already in the memory cache, it is automatically queried from the MySQL table, by default test.demo_test.

Download this Manual
User Comments
  Posted by Alex Nazaruk on July 1, 2014
you need to set up SELINUX to permissive because it will give you error: bind(): Permission denied, failed to listen on TCP port 11211: Permission denied

vi /etc/selinux/config

Centos, Redhat
Sign Up Login You must be logged in to post a comment.