Demonstation of PHP Memcache / MYSQL Wrapper Classes

This is a demonstration of PHP MySQL and Memcache wrapper classes that can be used to generically execute SQL queries that will automatically be cached by memcached when available. The code manages data in the memcache using name space keys and version numbers. Each data set should have a unique namespace, the version number for the name space is also stored in memcache and is incremented to invalidate cached data. The example uses a simple query as show below. The script is in three classes, class.cacheMemcache.php and class.DB.php contain the main code for MySQL queries using memcache, and class.DBQuery.php extends DB to illustrate a simple query using the classes. Note this example is using the memcache api and MYSQL.

Query: SELECT * FROM users

Found 3 rows:
  1. User 1
  2. User 2
  3. User 3

Cache Results

Memcache CONNECTED
Cache key debug - Key was set with ID- mykey-v1-a906449d5769fa7361d7ecc6aa3f6d28-a4fc5c1e8c543e92a123211bce782272 and TTL- 600
Query results retrieved from DATABASE.