Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F110670763
DivinerDiskCache.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, Apr 27, 11:24
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Apr 29, 11:24 (2 d)
Engine
blob
Format
Raw Data
Handle
25755193
Attached To
rPH Phabricator
DivinerDiskCache.php
View Options
<?php
abstract
class
DivinerDiskCache
extends
Phobject
{
private
$cache
;
public
function
__construct
(
$cache_directory
,
$name
)
{
$dir_cache
=
id
(
new
PhutilDirectoryKeyValueCache
())
->
setCacheDirectory
(
$cache_directory
);
$profiled_cache
=
id
(
new
PhutilKeyValueCacheProfiler
(
$dir_cache
))
->
setProfiler
(
PhutilServiceProfiler
::
getInstance
())
->
setName
(
$name
);
$this
->
cache
=
$profiled_cache
;
}
protected
function
getCache
()
{
return
$this
->
cache
;
}
public
function
delete
()
{
$this
->
getCache
()->
destroyCache
();
return
$this
;
}
/**
* Convert a long-form hash key like `ccbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaN` into
* a shortened directory form, like `cc/bb/aaaaaaaaN`. In conjunction with
* @{class:PhutilDirectoryKeyValueCache}, this gives us nice directories
* inside `.divinercache` instead of a million hash files with huge names at
* the top level.
*/
protected
function
getHashKey
(
$hash
)
{
return
implode
(
'/'
,
array
(
substr
(
$hash
,
0
,
2
),
substr
(
$hash
,
2
,
2
),
substr
(
$hash
,
4
,
8
),
));
}
}
Event Timeline
Log In to Comment