Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class ExtendedMemcache extends Memcache
- {
- protected $hash = array();
- function __construct()
- {}
- function getHash()
- {
- return $this->hash;
- }
- function setHash($arrHash)
- {
- $this->hash = $arrHash;
- }
- private function addGroupKeyAssoc($strGroup, $strKey)
- {
- $hash = $this->getHash();
- $hash[$strGroup][] = $strKey;
- $this->setHash($hash);
- }
- function set ($strGroup, $strKey, $value)
- {
- $this->addGroupKeyAssoc($strGroup, $strKey);
- parent::set($strKey, $value);
- }
- function deleteGroup($strGroup)
- {
- $hash = $this->getHash();
- $groupKeys = $hash[$strGroup];
- if (is_array($groupKeys)) foreach ($groupKeys as $groupKey) {
- $this->delete($groupKey);
- }
- }
- }
- $memcache = new ExentedMemcache();
- $memcache->set('thread123', 'posts.page5.offset10', $pagedPosts5);
- $memcache->set('thread123', 'posts.page6.offset10', $pagedPosts6);
- $memcache->set('thread123', 'posts.page7.offset11', $pagedPosts7);
- /// etc etc
- /// then to delete everything for the thread.
- $memcache->deleteGroup('thread123');
- /// w00t!
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement