# MemcachedLocker.class.php

Go to the documentation of this file.

    00001 <?php
    00002 /***************************************************************************
    00003  *   Copyright (C) 2009 by Denis M. Gabaidulin                             *
    00004  *                                                                         *
    00005  *   This program is free software; you can redistribute it and/or modify  *
    00006  *   it under the terms of the GNU Lesser General Public License as        *
    00007  *   published by the Free Software Foundation; either version 3 of the    *
    00008  *   License, or (at your option) any later version.                       *
    00009  *                                                                         *
    00010  ***************************************************************************/
    00011
    00018     final class MemcachedLocker extends BaseLocker implements Instantiatable
    00019     {
    00020         const VALUE = 0x1;
    00021
    00022         private $memcachedClient = null;
    00023
    00024         public static function me()
    00025         {
    00026             return Singleton::getInstance(__CLASS__);
    00027         }
    00028
    00029         public function setMemcachedClient(CachePeer $memcachedPeer)
    00030         {
    00031             $this->memcachedClient = $memcachedPeer;
    00032
    00033             return $this;
    00034         }
    00035
    00036         public function get($key)
    00037         {
    00038             return $this->memcachedClient->add(
    00039                 $key,
    00040                 self::VALUE,
    00041                 2 * Cache::EXPIRES_MINIMUM
    00042             );
    00043         }
    00044
    00045         public function free($key)
    00046         {
    00047             return $this->memcachedClient->delete($key);
    00048         }
    00049
    00050         public function drop($key)
    00051         {
    00052             return $this->free($key);
    00053         }
    00054     }
    00055 ?>