Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F543230
PhutilKeyValueCacheNamespace.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
PhutilKeyValueCacheNamespace.php
View Options
<?php
final
class
PhutilKeyValueCacheNamespace
extends
PhutilKeyValueCacheProxy
{
private
$namespace
;
public
function
setNamespace
(
$namespace
)
{
if
(
strpos
(
$namespace
,
':'
)
!==
false
)
{
throw
new
Exception
(
pht
(
"Namespace can't contain colons."
));
}
$this
->
namespace
=
$namespace
.
':'
;
return
$this
;
}
public
function
setKeys
(
array
$keys
,
$ttl
=
null
)
{
return
parent
::
setKeys
(
array_combine
(
$this
->
prefixKeys
(
array_keys
(
$keys
)),
$keys
),
$ttl
);
}
public
function
getKeys
(
array
$keys
)
{
$results
=
parent
::
getKeys
(
$this
->
prefixKeys
(
$keys
));
if
(!
$results
)
{
return
array
();
}
return
array_combine
(
$this
->
unprefixKeys
(
array_keys
(
$results
)),
$results
);
}
public
function
deleteKeys
(
array
$keys
)
{
return
parent
::
deleteKeys
(
$this
->
prefixKeys
(
$keys
));
}
private
function
prefixKeys
(
array
$keys
)
{
if
(
$this
->
namespace
==
null
)
{
throw
new
Exception
(
pht
(
'Namespace not set.'
));
}
$prefixed_keys
=
array
();
foreach
(
$keys
as
$key
)
{
$prefixed_keys
[]
=
$this
->
namespace
.
$key
;
}
return
$prefixed_keys
;
}
private
function
unprefixKeys
(
array
$keys
)
{
if
(
$this
->
namespace
==
null
)
{
throw
new
Exception
(
pht
(
'Namespace not set.'
));
}
$unprefixed_keys
=
array
();
foreach
(
$keys
as
$key
)
{
$unprefixed_keys
[]
=
substr
(
$key
,
strlen
(
$this
->
namespace
));
}
return
$unprefixed_keys
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 11:09 AM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
104588
Default Alt Text
PhutilKeyValueCacheNamespace.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment