Apache Zeta Components Manual :: File Source for apc_backend.php
Source for file apc_backend.php
Documentation is available at apc_backend.php
* File containing the ezcCacheApcBackend class.
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* This backend stores data in an APC cache.
* @apichange This class will be deprecated in the next major version of the
* Cache component. Please do not use it directly, but use {@link }
* ezcCacheStorageApc} instead.
* @version //autogentag//
* Constructs a new ezcCacheApcBackend object.
* @throws ezcBaseExtensionNotFoundException
* If the PHP apc extension is not installed.
* Stores the data $var under the key $key. Returns true or false depending
* on the success of the operation.
public function store( $key, $var, $ttl =
0 )
return apc_store( $key, $data, $ttl );
* Fetches the data associated with key $key.
public function fetch( $key )
$data =
apc_fetch( $key );
return ( is_object( $data ) ) ?
$data->var :
false;
* Deletes the data associated with key $key. Returns true or false depending
* on the success of the operation.
public function delete( $key )
return apc_delete( $key );
* Resets the complete backend.
* Marked private to not expose more of this interface to the user, since
* this will be removed in future versions.
// Kills the whole user cache
apc_clear_cache( "user" );
* Acquires a lock on the given $key.
* @param int $waitTime usleep()
* @param int $maxTime seconds
public function acquireLock( $key, $waitTime, $maxTime )
// add() does not replace and returns true on success. $maxTime is
// obeyed by Memcache expiry.
while ( apc_add( $key, time(), $maxTime ) ===
false )
// Don't check expiry time too frquently, since it requires restoring
if ( ( ++
$counter %
10 ===
0 ) &&
( time() - (int)
apc_fetch( $key ) >
$maxTime ) )
// Release expired lock and place own lock
apc_store( $key, time(), $maxTime );
* Releases a lock on the given $key.