1 | <?php |
||
24 | class MslsSqlCacher { |
||
25 | |||
26 | /** |
||
27 | * Database object |
||
28 | * |
||
29 | * @var object $db |
||
30 | */ |
||
31 | protected $db; |
||
32 | |||
33 | /** |
||
34 | * Name of the object which created this object |
||
35 | * |
||
36 | * @var string $caller |
||
37 | */ |
||
38 | protected $caller; |
||
39 | |||
40 | /** |
||
41 | * Parameters are used to create the key for the cached resultset |
||
42 | * |
||
43 | * @var mixed $params |
||
44 | */ |
||
45 | protected $params; |
||
46 | |||
47 | /** |
||
48 | * @param \WPDB $db |
||
49 | * @param $caller |
||
50 | */ |
||
51 | public function __construct( \WPDB $db, $caller ) { |
||
55 | |||
56 | /** |
||
57 | * Factory |
||
58 | * |
||
59 | * @uses \WPDB $wpdb |
||
60 | * |
||
61 | * @param string $caller |
||
62 | * |
||
63 | * @return MslsSqlCacher |
||
64 | */ |
||
65 | public static function init( $caller ) { |
||
70 | |||
71 | /** |
||
72 | * Set params |
||
73 | * |
||
74 | * @param mixed $params |
||
75 | * |
||
76 | * @return MslsSqlCacher |
||
77 | */ |
||
78 | public function set_params( $params ) { |
||
83 | |||
84 | /** |
||
85 | * Get the name of the key which is in use for the cached object |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | public function get_key() { |
||
98 | |||
99 | /** |
||
100 | * Magic __get |
||
101 | * |
||
102 | * @param string $key |
||
103 | * |
||
104 | * @return mixed |
||
105 | */ |
||
106 | public function __get( $key ) { |
||
109 | |||
110 | /** |
||
111 | * Call a method of the db-object with the needed args and cache the result |
||
112 | * |
||
113 | * @param string $method |
||
114 | * @param array $args |
||
115 | * |
||
116 | * @return mixed |
||
117 | */ |
||
118 | public function __call( $method, $args ) { |
||
132 | |||
133 | } |
||
134 |