PluginProbe
Polylang / 1.8
Polylang v1.8
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
← All changes | include/cache.php +15 -35 3.01.8 View file →
@@ -1,67 +1,50 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 -/**
7 - * An extremely simple non persistent cache system
3 +/*
4 + * an extremely simple non persistent cache system
8 5 * not as fast as using directly an array but more readable
9 6 *
10 7 * @since 1.7
11 8 */
12 9 class PLL_Cache {
13 - /**
14 - * Current site id.
15 - *
16 - * @var int
17 - */
18 - protected $blog_id;
10 + protected $blog_id, $cache;
19 11
20 - /**
21 - * The cache container.
12 + /*
13 + * constructor
22 14 *
23 - * @var array
24 - */
25 - protected $cache;
26 -
27 - /**
28 - * Constructor
29 - *
30 15 * @since 1.7
31 16 */
32 17 public function __construct() {
33 18 $this->blog_id = get_current_blog_id();
34 - add_action( 'switch_blog', array( $this, 'switch_blog' ) );
19 + add_action( 'switch_blog', array( &$this, 'switch_blog' ) );
35 20 }
36 21
37 - /**
38 - * Called when switching blog
22 + /*
23 + * called when switching blog
39 24 *
40 25 * @since 1.7
41 26 *
42 27 * @param int $new_blog
43 - * @return void
44 28 */
45 29 public function switch_blog( $new_blog ) {
46 30 $this->blog_id = $new_blog;
47 31 }
48 32
49 - /**
50 - * Add a value in cache
33 + /*
34 + * add a value in cache
51 35 *
52 36 * @since 1.7
53 37 *
54 38 * @param string $key
55 - * @param mixed $data
56 - * @return void
39 + * @param mixed $data
57 40 */
58 41 public function set( $key, $data ) {
59 42 $this->cache[ $this->blog_id ][ $key ] = $data;
60 43 }
61 44
62 - /**
63 - * Get value from cache
45 + /*
46 + * get value from cache
64 47 *
65 48 * @since 1.7
66 49 *
67 50 * @param string $key
@@ -70,15 +53,12 @@
70 53 public function get( $key ) {
71 54 return isset( $this->cache[ $this->blog_id ][ $key ] ) ? $this->cache[ $this->blog_id ][ $key ] : false;
72 55 }
73 56
74 - /**
75 - * Clean the cache (for this blog only)
57 + /*
58 + * clean the cache (for this blog only)
76 59 *
77 60 * @since 1.7
78 - *
79 - * @param string $key
80 - * @return void
81 61 */
82 62 public function clean( $key = '' ) {
83 63 if ( empty( $key ) ) {
84 64 unset( $this->cache[ $this->blog_id ] );