1 | <?php |
||
27 | class MslsSqlCacher { |
||
28 | |||
29 | /** |
||
30 | * Database object |
||
31 | * |
||
32 | * @var object $db |
||
33 | */ |
||
34 | protected $db; |
||
35 | |||
36 | /** |
||
37 | * Name of the object which created this object |
||
38 | * |
||
39 | * @var string $caller |
||
40 | */ |
||
41 | protected $caller; |
||
42 | |||
43 | /** |
||
44 | * Parameters are used to create the key for the cached resultset |
||
45 | * |
||
46 | * @var mixed $params |
||
47 | */ |
||
48 | protected $params; |
||
49 | |||
50 | /** |
||
51 | * Constructor |
||
52 | * |
||
53 | * @param \WPDB $db |
||
54 | * @param $caller |
||
55 | */ |
||
56 | public function __construct( \WPDB $db, $caller ) { |
||
60 | |||
61 | /** |
||
62 | * Factory |
||
63 | * |
||
64 | * @uses \WPDB $wpdb |
||
65 | * |
||
66 | * @param string $caller |
||
67 | * |
||
68 | * @return MslsSqlCacher |
||
69 | */ |
||
70 | public static function init( $caller ) { |
||
75 | |||
76 | /** |
||
77 | * Set params |
||
78 | * |
||
79 | * @param mixed $params |
||
80 | * |
||
81 | * @return MslsSqlCacher |
||
82 | */ |
||
83 | public function set_params( $params ) { |
||
88 | |||
89 | /** |
||
90 | * Get the name of the key which is in use for the cached object |
||
91 | * |
||
92 | * @return string |
||
93 | */ |
||
94 | public function get_key() { |
||
103 | |||
104 | /** |
||
105 | * Magic __get |
||
106 | * |
||
107 | * @param string $key |
||
108 | * |
||
109 | * @return mixed |
||
110 | */ |
||
111 | public function __get( $key ) { |
||
114 | |||
115 | /** |
||
116 | * Call a method of the db-object with the needed args and cache the result |
||
117 | * |
||
118 | * @param string $method |
||
119 | * @param array $args |
||
120 | * |
||
121 | * @return mixed |
||
122 | */ |
||
123 | public function __call( $method, $args ) { |
||
137 | |||
138 | } |
||
139 |