Chapter 10. Memcached Functions for MySQL

You were introduced to memcached in Chapter 8 where you learned about Cache::Memcached and how to write programs to use memcached. In Chapter 9, you learned about libmemcached, a faster client library. So, you should now have a good idea how to use memcached with Perl.

What about memcached and MySQL? Is there any sort of interoperability between the two, since they are so commonly used together? It would be great if there was some sort of "glue" between the two, without having to write Perl code, to get data to and from MySQL and memcached.

Well there is. This is why the Memcached Functions for MySQL, aka memcached UDFs, were written.

What Are Memcached Functions for MySQL?

MySQL has an API for writing user-defined functions (otherwise known as UDFs), as you learned in Chapter 3. There, you saw the example of a UDF using libcurl. Because the UDF API is so flexible, it's possible to write many different functions to do a number of things. With the advent of libmemcached, it became obvious that there could be UDFs that interact with memcached through libmemcached and provide all the functionality that one would normally implement with an external language at the application layer.

The Memcached Functions for MySQL, written by Patrick Galbraith and Brian Aker, are a suite of functions available to use with MySQL that allow you to store, retrieve, and delete data, as well as perform most of the functions/operations that are available with libmemcached, ...

Get Developing Web Applications with Perl, memcached, MySQL® and Apache now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.