OptimizerSegmentHandler.class.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  *   Copyright (C) 2006-2007 by Konstantin V. Arkhipov                     *
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 /* $Id: OptimizerSegmentHandler.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012 
00016     abstract class OptimizerSegmentHandler implements SegmentHandler
00017     {
00018         protected $id       = null;
00019         protected $locker   = null;
00020         
00021         abstract protected function getMap();
00022         abstract protected function storeMap(array $map);
00023         
00024         public function __construct($segmentId)
00025         {
00026             $this->id = $segmentId;
00027         }
00028         
00029         public function touch($key)
00030         {
00031             $map = $this->getMap();
00032             
00033             if (!isset($map[$key])) {
00034                 $map[$key] = true;
00035                 return $this->storeMap($map);
00036             }
00037             
00038             $this->locker->free($this->id);
00039             return true;
00040         }
00041         
00042         public function unlink($key)
00043         {
00044             $map = $this->getMap();
00045             
00046             if (isset($map[$key])) {
00047                 unset($map[$key]);
00048                 return $this->storeMap($map);
00049             }
00050             
00051             $this->locker->free($this->id);
00052             return true;
00053         }
00054         
00055         public function ping($key)
00056         {
00057             $map = $this->getMap();
00058             
00059             $this->locker->free($this->id);
00060             
00061             if (isset($map[$key])) {
00062                 return true;
00063             } else {
00064                 return false;
00065             }
00066         }
00067     }
00068 ?>

Generated on Sun Dec 9 21:56:23 2007 for onPHP by  doxygen 1.5.4