00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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 ?>