Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
generateItems example
return
(
self::
$createCacheItem
)
(
$key
,
$item
,
$this
->poolHash
)
;
}
public
function
getItems
(
array
$keys
=
[
]
)
: iterable
{
if
(
$this
->namespaceLen
)
{
foreach
(
$keys
as
$i
=>
$key
)
{
$keys
[
$i
]
=
$this
->
getId
(
$key
)
;
}
}
return
$this
->
generateItems
(
$this
->pool->
getItems
(
$keys
)
)
;
}
public
function
hasItem
(
mixed
$key
)
: bool
{
return
$this
->pool->
hasItem
(
$this
->
getId
(
$key
)
)
;
}
public
function
clear
(
string
$prefix
= ''
)
: bool
{
if
(
$this
->pool instanceof AdapterInterface
)
{
return
$this
->pool->
clear
(
$this
->namespace.
$prefix
)
;
}
$this
->
commit
(
)
;
}
try
{
$items
=
$this
->
doFetch
(
$ids
)
;
}
catch
(
\Exception
$e
)
{
CacheItem::
log
(
$this
->logger, 'Failed to fetch items: '.
$e
->
getMessage
(
)
,
[
'keys' =>
$keys
, 'exception' =>
$e
, 'cache-adapter' =>
get_debug_type
(
$this
)
]
)
;
$items
=
[
]
;
}
$ids
=
array_combine
(
$ids
,
$keys
)
;
return
$this
->
generateItems
(
$items
,
$ids
)
;
}
public
function
save
(
CacheItemInterface
$item
)
: bool
{
if
(
!
$item
instanceof CacheItem
)
{
return
false;
}
$this
->deferred
[
$item
->
getKey
(
)
]
=
$item
;
return
$this
->
commit
(
)
;
}
return
$callback
(
(
self::
$createCacheItem
)
(
$key
)
,
$save
)
;
}
public
function
getItem
(
mixed
$key
)
: CacheItem
{
return
(
self::
$createCacheItem
)
(
$key
)
;
}
public
function
getItems
(
array
$keys
=
[
]
)
: iterable
{
return
$this
->
generateItems
(
$keys
)
;
}
public
function
hasItem
(
mixed
$key
)
: bool
{
return
false;
}
public
function
clear
(
string
$prefix
= ''
)
: bool
{
return
true;
}
else
{
$value
=
$this
->storeSerialized ?
$this
->
unfreeze
(
$key
,
$isHit
)
:
$this
->values
[
$key
]
;
}
return
(
self::
$createCacheItem
)
(
$key
,
$value
,
$isHit
,
$this
->tags
[
$key
]
?? null
)
;
}
public
function
getItems
(
array
$keys
=
[
]
)
: iterable
{
\
assert
(
self::
validateKeys
(
$keys
)
)
;
return
$this
->
generateItems
(
$keys
,
microtime
(
true
)
, self::
$createCacheItem
)
;
}
public
function
deleteItem
(
mixed
$key
)
: bool
{
\
assert
(
'' !== CacheItem::
validateKey
(
$key
)
)
;
unset
(
$this
->values
[
$key
]
,
$this
->tags
[
$key
]
,
$this
->expiries
[
$key
]
)
;
return
true;
}
public
function
deleteItems
(
array
$keys
)
: bool
{
public
function
getItems
(
array
$keys
=
[
]
)
: iterable
{
foreach
(
$keys
as
$key
)
{
if
(
!\
is_string
(
$key
)
)
{
throw
new
InvalidArgumentException
(
sprintf
(
'Cache key must be string, "%s" given.',
get_debug_type
(
$key
)
)
)
;
}
}
if
(
!
isset
(
$this
->values
)
)
{
$this
->
initialize
(
)
;
}
return
$this
->
generateItems
(
$keys
)
;
}
public
function
hasItem
(
mixed
$key
)
: bool
{
if
(
!\
is_string
(
$key
)
)
{
throw
new
InvalidArgumentException
(
sprintf
(
'Cache key must be string, "%s" given.',
get_debug_type
(
$key
)
)
)
;
}
if
(
!
isset
(
$this
->values
)
)
{
$this
->
initialize
(
)
;
}
return
$item
;
}
$misses
[
$i
]
=
$item
;
}
return
$item
;
}
public
function
getItems
(
array
$keys
=
[
]
)
: iterable
{
return
$this
->
generateItems
(
$this
->adapters
[
0
]
->
getItems
(
$keys
)
, 0
)
;
}
private
function
generateItems
(
iterable
$items
, int
$adapterIndex
)
: \Generator
{
$missing
=
[
]
;
$misses
=
[
]
;
$nextAdapterIndex
=
$adapterIndex
+ 1;
$nextAdapter
=
$this
->adapters
[
$nextAdapterIndex
]
?? null;
foreach
(
$items
as
$k
=>
$item
)
{
if
(
!
$nextAdapter
||
$item
->
isHit
(
)
)
{