Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

apc.php
Go to the documentation of this file.
1 <?php
11 class ezpRestCacheStorageApcCluster extends ezcCacheStorageApcPlain
12 {
16 protected $expiryHandler;
17
23 public $forceStoreRegistry = false;
24
25 public function __construct( $location = null, array $options = array() )
26 {
27 $this->expiryHandler = eZExpiryHandler::instance();
28
29 parent::__construct( $location, $options );
30 }
31
37 public function restore( $id, $attributes = array(), $search = false )
38 {
39 $ttl = (int)eZINI::instance( 'rest.ini' )->variable( 'CacheSettings', 'RouteApcCacheTTL' );
40 $currentTime = time();
41 $expiryTime = $this->getExpiryTime( $id );
42
43 // Check if cache is marked as expired in expiry.php
44 // Mandatory in clustered environment for cache control
45 $isCacheInternallyExpired = false;
46 if( $expiryTime < ( $currentTime - $ttl ) )
47 {
48 $isCacheInternallyExpired = true;
49 }
50
51 if( !$isCacheInternallyExpired ) // Cache not marked as expired in expiry.php, defer cache retore to parent class
52 {
53 return parent::restore( $id, $attributes, $search );
54 }
55 else // Cache is expired in expiry.php, return false as we must regenerate it
56 {
57 parent::delete( $id, $attributes, $search ); // Directly go to the parent not to force registry store, to avoid potential cache slam
58 return false;
59 }
60 }
61
66 protected function getExpiryTime( $id )
67 {
68 $storedTimeStamp = $this->expiryHandler->hasTimestamp( $id ) ? $this->expiryHandler->timestamp( $id ) : false;
69 $expiryTime = $storedTimeStamp !== false ? $storedTimeStamp : 0;
70
71 return $expiryTime;
72 }
73
79 protected function storeSearchRegistry()
80 {
81 $location = $this->properties['location'];
82 if( $this->forceStoreRegistry )
83 {
84 if( isset( $this->searchRegistry[$location] ) )
85 {
86 $this->forceStoreRegistry = false;
87 parent::storeSearchRegistry();
88 }
89 }
90 }
91
97 public function store( $id, $data, $attributes = array() )
98 {
99 $this->forceStoreRegistry = true;
100 $storeResult = parent::store( $id, $data, $attributes );
101
102 // Update clustered expiry timestamp
103 $expiryTime = time() + $this->properties['options']['ttl'];
104 $this->expiryHandler->setTimestamp( ezpRestRouter::ROUTE_CACHE_KEY, $expiryTime );
105
106 return $storeResult;
107 }
108
113 public function delete( $id = null, $attributes = array(), $search = false )
114 {
115 $this->forceStoreRegistry = true;
116 parent::delete( $id, $attributes, $search );
117 }
118 }
119 ?>
ezpRestCacheStorageApcCluster
Definition: apc.php:12
ezpRestCacheStorageApcCluster\restore
restore( $id, $attributes=array(), $search=false)
Definition: apc.php:37
ezpRestCacheStorageApcCluster\$expiryHandler
$expiryHandler
Definition: apc.php:16
ezpRestCacheStorageApcCluster\getExpiryTime
getExpiryTime( $id)
Definition: apc.php:66
ezpRestCacheStorageApcCluster\__construct
__construct( $location=null, array $options=array())
Definition: apc.php:25
ezpRestCacheStorageApcCluster\storeSearchRegistry
storeSearchRegistry()
Definition: apc.php:79
ezpRestCacheStorageApcCluster\store
store( $id, $data, $attributes=array())
Definition: apc.php:97
ezpRestCacheStorageApcCluster\$forceStoreRegistry
$forceStoreRegistry
Definition: apc.php:23
ezpRestRouter\ROUTE_CACHE_KEY
const ROUTE_CACHE_KEY
Definition: router.php:14
$id
$id
Definition: companytypelist.php:193
$search
$search
Definition: export_froogle.php:153
properties
$def properties['rest_client_id']
Definition: ezprestauthorizedclient.php:21
$options
$options
Definition: optionlist.php:56
$location
$location
Definition: user/gotolink.php:43
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.