SHOW:
|
|
- or go back to the newest paste.
| 1 | - | if (!$data = $this->load($key)) {
|
| 1 | + | class Data |
| 2 | - | $data = $this->save($key, function() use ($db) {
|
| 2 | + | {
|
| 3 | - | return $db->query(...); |
| 3 | + | public function __construct($db, $storage) |
| 4 | - | }, array( |
| 4 | + | {
|
| 5 | - | Cache::TAGS => array(...), |
| 5 | + | $this->db = $db; |
| 6 | - | ... |
| 6 | + | $this->cache = new Cache($storage, ...); |
| 7 | - | )) |
| 7 | + | } |
| 8 | - | } |
| 8 | + | |
| 9 | public function getSometing($user) | |
| 10 | {
| |
| 11 | if (!$data = $this->cache->load($key)) {
| |
| 12 | $db = $this->db; | |
| 13 | $data = $this->cache->save($key, function() use ($db, $user) {
| |
| 14 | return $db->query(...); | |
| 15 | ||
| 16 | }, array( | |
| 17 | Cache::TAGS => array(...), | |
| 18 | ... | |
| 19 | )) | |
| 20 | } | |
| 21 | ||
| 22 | return $data; | |
| 23 | } | |
| 24 | ||
| 25 | } | |
| 26 | ||
| 27 | ||
| 28 | $data = new Data($db, $storage); | |
| 29 | $this->template->results = $data->getSometing($user); |