Implementation of Drupal Memcache in custom modules
I am developing lots of custom modules for my web application and needs to im开发者_运维问答plement memcache with it. I have installed and enabled memcache module in my drupal installation but now I have to see what data is being cached.
Is there any additional work required to cache my module specific data? Also, What is the exact work flow of caching mechanism in Drupal?
Regards,
Once set up correctly the memcache module overrides the standard Drupal cache functions, so your module dosen't need to be memcache aware. It will use memcache on systems with it enabled and standard Drupal db caching elsewhere.
The memcache module requires a bit more work to enable than most other modules.
These are the broad steps you need to take in order to use this software. Order is important.
- Install the memcached binaries on your server. See How to install Memcache on Debian Etch or How to install Memcache on OSX
- Install the PECL memcache extension for PHP.
- In php.ini set memcache.hash_strategy="consistent".
- Put your site into offline mode.
- Download and install the memcache module.
- If you have previously been running the memcache module, run update.php.
- Apply the DRUPAL-5-cache-serialize.patch that comes with the module to your Drupal installation.
- Start at least one instance of memcached on your server.
- Edit settings.php to configure the servers, clusters and bins that memcache is supposed to use.
- Edit settings.php to include either memcache.inc or memcache.db.inc. For example, $conf['cache_inc'] ='sites/all/modules/memcache/memcache.db.inc';
- Bring your site back online.
Once installed and running you can telnet to the memcache instance on your server (11211 I belive is the default port) and type get *cache-key*
to see if your data has been cached.
精彩评论