PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.1.4.3
Pods – Custom Content Types and Fields v3.1.4.3
2.7.31.4 2.8.23.5 2.9.19.5 3.0.10.5 3.1.4.3 3.2.8.4 3.3.9.2 2.8.23.4 2.9.19.4 3.0.10.4 3.1.4.2 3.2.8.3 3.3.9.1 trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / src / Pods / Static_Cache.php
pods / src / Pods Last commit date
API 1 day ago Admin 1 day ago Blocks 1 day ago CLI 1 day ago Container 1 day ago Data 1 day ago Integrations 1 day ago REST 1 day ago Theme 1 day ago Tools 1 day ago Whatsit 1 day ago Config_Handler.php 1 day ago Integration.php 1 day ago Permissions.php 1 day ago Pod_Manager.php 1 day ago Service_Provider.php 1 day ago Service_Provider_Base.php 1 day ago Service_Provider_Fallback.php 1 day ago Static_Cache.php 1 day ago Whatsit.php 1 day ago Wisdom_Tracker.php 1 day ago
Static_Cache.php
107 lines
1 <?php
2
3 namespace Pods;
4
5 /**
6 * Static cache class used for storing on-page cached vars but not storing them into the object cache
7 * with support for multisite. Each site has their own cache.
8 *
9 * @since 2.8
10 */
11 class Static_Cache {
12
13 /**
14 * The cache array.
15 *
16 * @since 2.8
17 *
18 * @var array
19 */
20 protected static $cache = [];
21
22 /**
23 * Get the cache value from the cache.
24 *
25 * @since 2.8
26 *
27 * @param string $key The cache key.
28 * @param string $group The cache group.
29 *
30 * @return mixed|false The cache value from the cache.
31 */
32 public function get( $key, $group = 'global' ) {
33 $blog_id = get_current_blog_id();
34
35 if ( ! isset( self::$cache[ $blog_id ][ $group ][ $key ] ) ) {
36 return false;
37 }
38
39 return self::$cache[ $blog_id ][ $group ][ $key ];
40 }
41
42 /**
43 * Set the cache value in the cache.
44 *
45 * @since 2.8
46 *
47 * @param string $key The cache key.
48 * @param mixed $value The cache value.
49 * @param string $group The cache group.
50 */
51 public function set( $key, $value, $group = 'global' ) {
52 $blog_id = get_current_blog_id();
53
54 if ( ! isset( self::$cache[ $blog_id ] ) ) {
55 self::$cache[ $blog_id ] = [];
56 }
57
58 if ( ! isset( self::$cache[ $blog_id ][ $group ] ) ) {
59 self::$cache[ $blog_id ][ $group ] = [];
60 }
61
62 self::$cache[ $blog_id ][ $group ][ $key ] = $value;
63 }
64
65 /**
66 * Delete the cache value from the cache.
67 *
68 * @since 2.8
69 *
70 * @param string $key The cache key.
71 * @param string $group The cache group.
72 */
73 public function delete( $key, $group = 'global' ) {
74 $blog_id = get_current_blog_id();
75
76 if ( ! isset( self::$cache[ $blog_id ][ $group ][ $key ] ) ) {
77 return false;
78 }
79
80 unset( self::$cache[ $blog_id ][ $group ][ $key ] );
81
82 return true;
83 }
84
85 /**
86 * Flush the cache.
87 *
88 * @since 2.8
89 *
90 * @param string $group The cache group.
91 */
92 public function flush( $group = null ) {
93 $blog_id = get_current_blog_id();
94
95 if ( $group ) {
96 if ( ! isset( self::$cache[ $blog_id ] ) ) {
97 self::$cache[ $blog_id ] = [];
98 }
99
100 self::$cache[ $blog_id ][ $group ] = [];
101 } else {
102 self::$cache[ $blog_id ] = [];
103 }
104 }
105
106 }
107