PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.2.8.3
Pods – Custom Content Types and Fields v3.2.8.3
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 2 weeks ago Admin 2 weeks ago Blocks 2 weeks ago CLI 2 weeks ago Container 2 weeks ago Data 2 weeks ago Integrations 2 weeks ago REST 2 weeks ago Theme 2 weeks ago Tools 2 weeks ago WP 2 weeks ago Whatsit 2 weeks ago Config_Handler.php 2 weeks ago Integration.php 2 weeks ago Permissions.php 2 weeks ago Pod_Manager.php 2 weeks ago Service_Provider.php 2 weeks ago Service_Provider_Base.php 2 weeks ago Static_Cache.php 2 weeks ago Whatsit.php 2 weeks ago Wisdom_Tracker.php 2 weeks 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