Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Data
- {
- public function __construct($db, $storage)
- {
- $this->db = $db;
- $this->cache = new Cache($storage, ...);
- }
- public function getSometing($user)
- {
- if (!$data = $this->cache->load($key)) {
- $db = $this->db;
- $data = $this->cache->save($key, function() use ($db, $user) {
- return $db->query(...);
- }, array(
- Cache::TAGS => array(...),
- ...
- ))
- }
- return $data;
- }
- }
- $data = new Data($db, $storage);
- $this->template->results = $data->getSometing($user);
Advertisement
Add Comment
Please, Sign In to add comment