简体   繁体   中英

Confusion with new innodb memcached plugin for MYSQL?

I already have memcached running alongside the memcache php extension in the traditional manner with my app set up to cache queries when intended.

I am now running MySQL 5.6 and would like to test out the new innodb_memcached plugin for fast NoSQL style key value access to certain tables in my database.

However I am confused regarding the installation:

  • Since I already have memcached installed should I uninstall it and then install the innodb plugin version? (Which was in my case installed via yum)
  • If so, will my app function correctly and still cache queries in the usual manner? Or will all of this be invalidated?
  • Should I install it alongside the standard version and run it on a separate port? If so how would I go about this?

Basically I would just like some advice regarding this install. I am hoping its a simple uninstall and replacement, with everything else running as it did before.

Thanks in advance

As always the answer is "it depends".

You can use the memcached plugin as a complete replacement of your existing standard memcached server. You would only need to tell the plugin which table you want to use to store the cached data by inserting a row into the innodb_memcache.containers table. In this case you would probably create a brand new table for your cache. In this scenario your application and existing database remains untouched. The benefit is that you now have a persistent memcached with as much space as your database has (instead of being limited by the amount of RAM on your memcached server)

However, there is also another approach you can take, in which you access your actual MySQL data but exclusively through the Memcached protocol. In this scenario you completely remove the SQL interactions from your app, and only use your memcached client to add/delete/update your data. Obviously this may or may not be applicable to your particular use case, but if you can pull it off, then it simplifies your application A LOT, by doing caching AND permanent storage in one single shot.

To use the second approach, you again need to configure the innodb_memcache.containers table to correctly map to the target table. You can even have multiple tables exposed via the same memcached interface, just by adding more rows to this table and prefixing your keys with @@identifier.

For example: @@users.1234 would use the users container (mapped to table XYZ) and use 1234 as the caching key)

As complement on previous answer, check the standard documentation for step by step configuration: http://dev.mysql.com/doc/refman/5.6/en/innodb-memcached-setup.html

Basically you can choose which port to configure it (the innodb memcached plugin) It runs as part of MySQL server (but the memcached port is different than the standard MySQL port).

And yes, can be chose either as replacement of standard memcached, or as persistence layer for memcached itself (in which case, it will be necessary to do extra programming to persist the main memcached).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM