-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKeyFormat.php
More file actions
56 lines (46 loc) · 1.1 KB
/
KeyFormat.php
File metadata and controls
56 lines (46 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace WPMultiObjectCache;
class KeyFormat
{
/**
* @var CurrentBlogManager Blog Manager
*/
private $blogManager;
/**
* KeyFormat constructor.
*
* @param CurrentBlogManager $blogManager
*/
public function __construct(CurrentBlogManager $blogManager)
{
$this->blogManager = $blogManager;
}
/**
* Gets the cache key format to be used
*
* @return string
*/
public function get()
{
global $table_prefix;
// Allow for multiple sites to use the same Object Cache.
$key_format = $table_prefix . '%s';
if ($this->isMultiSite()) {
$key_format = $this->blogManager->getBlogID() . '.%s';
}
return WP_CACHE_KEY_SALT . $key_format;
}
/**
* Determines if we are in a multi-site environment.
*
* @return bool
*/
private function isMultiSite()
{
static $multiSite;
if (null === $multiSite) {
$multiSite = (function_exists('is_multisite') && is_multisite());
}
return $multiSite;
}
}