Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F539578
PhabricatorKeyValueSerializingCacheProxy.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PhabricatorKeyValueSerializingCacheProxy.php
View Options
<?php
/**
* Proxies another cache and serializes values.
*
* This allows more complex data to be stored in a cache which can only store
* strings.
*/
final
class
PhabricatorKeyValueSerializingCacheProxy
extends
PhutilKeyValueCacheProxy
{
public
function
getKeys
(
array
$keys
)
{
$results
=
parent
::
getKeys
(
$keys
);
$reads
=
array
();
foreach
(
$results
as
$key
=>
$result
)
{
$structure
=
@
unserialize
(
$result
);
// The unserialize() function returns false when unserializing a
// literal `false`, and also when it fails. If we get a literal
// `false`, test if the serialized form is the same as the
// serialization of `false` and miss the cache otherwise.
if
(
$structure
===
false
)
{
static
$serialized_false
;
if
(
$serialized_false
===
null
)
{
$serialized_false
=
serialize
(
false
);
}
if
(
$result
!==
$serialized_false
)
{
continue
;
}
}
$reads
[
$key
]
=
$structure
;
}
return
$reads
;
}
public
function
setKeys
(
array
$keys
,
$ttl
=
null
)
{
$writes
=
array
();
foreach
(
$keys
as
$key
=>
$value
)
{
if
(
is_object
(
$value
))
{
throw
new
Exception
(
pht
(
'Serializing cache can not write objects (for key "%s")!'
,
$key
));
}
$writes
[
$key
]
=
serialize
(
$value
);
}
return
parent
::
setKeys
(
$writes
,
$ttl
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 9:13 AM (1 d, 23 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
96613
Default Alt Text
PhabricatorKeyValueSerializingCacheProxy.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment