PluginProbe
Polylang / 1.7.3
Polylang v1.7.3
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
polylang / include / cache.php

cache.php in Polylang 1.7.3, at include/cache.php

66 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * an extremely simple non persistent cache system
4 * not as fast as using directly an array but more readable
5 *
6 * @since 1.7
7 */
8 class PLL_Cache {
9 protected $blog_id, $cache;
10
11 /*
12 * constructor
13 *
14 * @since 1.7
15 */
16 public function __construct() {
17 $this->blog_id = get_current_blog_id();
18 add_action('switch_blog', array(&$this, 'switch_blog'));
19 }
20
21 /*
22 * called when switching blog
23 *
24 * @since 1.7
25 *
26 * @param int $new_blog
27 */
28 public function switch_blog($new_blog) {
29 $this->blog_id = $new_blog;
30 }
31
32 /*
33 * add a value in cache
34 *
35 * @since 1.7
36 *
37 * @param string $key
38 * @param mixed $data
39 */
40 public function set($key, $data) {
41 $this->cache[$this->blog_id][$key] = $data;
42 }
43
44 /*
45 * get value from cache
46 *
47 * @since 1.7
48 *
49 * @param string $key
50 * @return mixed $data
51 */
52 public function get($key) {
53 return isset($this->cache[$this->blog_id][$key]) ? $this->cache[$this->blog_id][$key] : false;
54 }
55
56 /*
57 * clean the cache (for this blog only)
58 *
59 * @since 1.7
60 */
61 public function clean() {
62 unset($this->cache[$this->blog_id]);
63 }
64
65 }
66