XCacheSegmentHandler.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 
00017     final class XCacheSegmentHandler extends OptimizerSegmentHandler
00018     {
00019         public function __construct($segmentId)
00020         {
00021             parent::__construct($segmentId);
00022             
00023             $this->locker = SemaphorePool::me();
00024         }
00025         
00026         public function drop()
00027         {
00028             return xcache_unset($this->id);
00029         }
00030         
00031         public function ping($key)
00032         {
00033             if (xcache_isset($this->id))
00034                 return parent::ping($key);
00035             else
00036                 return false;
00037         }
00038         
00039         protected function getMap()
00040         {
00041             $this->locker->get($this->id);
00042             
00043             if (!$map = xcache_get($this->id)) {
00044                 $map = array();
00045             }
00046             
00047             return $map;
00048         }
00049         
00050         protected function storeMap(array $map)
00051         {
00052             $result = xcache_set($this->id, $map);
00053             
00054             $this->locker->free($this->id);
00055             
00056             return $result;
00057         }
00058     }
00059 ?>