Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
APCUIterator example
/** * {@inheritdoc} */
public
function
testSetGet
(
)
{
parent::
testSetGet
(
)
;
// Make sure entries are permanent (i.e. no TTL).
$backend
=
$this
->
getCacheBackend
(
$this
->
getTestBin
(
)
)
;
$key
=
$backend
->
getApcuKey
(
'TEST8'
)
;
$iterator
=
new
\
APCUIterator
(
'/^' .
$key
. '/'
)
;
foreach
(
$iterator
as
$item
)
{
$this
->
assertEquals
(
0,
$item
[
'ttl'
]
)
;
$found
= TRUE;
}
$this
->
assertTrue
(
$found
)
;
}
}
}
protected
function
doHave
(
string
$id
)
: bool
{
return
apcu_exists
(
$id
)
;
}
protected
function
doClear
(
string
$namespace
)
: bool
{
return
isset
(
$namespace
[
0
]
)
&&
class_exists
(
\APCUIterator::
class
, false
)
&&
(
'cli' !== \PHP_SAPI ||
filter_var
(
\
ini_get
(
'apc.enable_cli'
)
, \FILTER_VALIDATE_BOOL
)
)
?
apcu_delete
(
new
\
APCUIterator
(
sprintf
(
'/^%s/',
preg_quote
(
$namespace
, '/'
)
)
, \APC_ITER_KEY
)
)
:
apcu_clear_cache
(
)
;
}
protected
function
doDelete
(
array
$ids
)
: bool
{
foreach
(
$ids
as
$id
)
{
apcu_delete
(
$id
)
;
}
return
true;
}
protected
function
getIterator
(
$search
= NULL,
$format
= APC_ITER_ALL,
$chunk_size
= 100,
$list
= APC_LIST_ACTIVE
)
{
return
new
\
APCUIterator
(
$search
,
$format
,
$chunk_size
,
$list
)
;
}
}