ApcSegmentHandler.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 ApcSegmentHandler 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 apc_delete($this->id);
00029         }
00030         
00031         protected function getMap()
00032         {
00033             $this->locker->get($this->id);
00034             
00035             if (!$map = apc_fetch($this->id)) {
00036                 $map = array();
00037             }
00038             
00039             return $map;
00040         }
00041         
00042         protected function storeMap(array $map)
00043         {
00044             $result = apc_store($this->id, $map, Cache::EXPIRES_FOREVER);
00045             
00046             $this->locker->free($this->id);
00047             
00048             return $result;
00049         }
00050     }
00051 ?>