Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96083531
PhutilKeyValueCacheAPC.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Dec 22, 11:01
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Dec 24, 11:01 (2 d)
Engine
blob
Format
Raw Data
Handle
23117001
Attached To
rPHU libphutil
PhutilKeyValueCacheAPC.php
View Options
<?php
/**
* Interface to the APC key-value cache. This is a very high-performance cache
* which is local to the current machine.
*/
final
class
PhutilKeyValueCacheAPC
extends
PhutilKeyValueCache
{
/* -( Key-Value Cache Implementation )------------------------------------- */
public
function
isAvailable
()
{
return
function_exists
(
'apc_fetch'
)
&&
ini_get
(
'apc.enabled'
)
&&
(
ini_get
(
'apc.enable_cli'
)
||
php_sapi_name
()
!=
'cli'
);
}
public
function
getKeys
(
array
$keys
,
$ttl
=
null
)
{
$results
=
array
();
$fetched
=
false
;
foreach
(
$keys
as
$key
)
{
$result
=
apc_fetch
(
$key
,
$fetched
);
if
(
$fetched
)
{
$results
[
$key
]
=
$result
;
}
}
return
$results
;
}
public
function
setKeys
(
array
$keys
,
$ttl
=
null
)
{
// NOTE: Although modern APC supports passing an array to `apc_store()`,
// it is not supported by older version fo APC or by HPHP.
foreach
(
$keys
as
$key
=>
$value
)
{
apc_store
(
$key
,
$value
,
$ttl
);
}
return
$this
;
}
public
function
deleteKeys
(
array
$keys
)
{
foreach
(
$keys
as
$key
)
{
apc_delete
(
$key
);
}
return
$this
;
}
public
function
destroyCache
()
{
apc_clear_cache
(
'user'
);
return
$this
;
}
}
Event Timeline
Log In to Comment