HosipLan

Untitled

Mar 27th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Data
  2. {
  3.     public function __construct($db, $storage)
  4.     {
  5.         $this->db = $db;
  6.         $this->cache = new Cache($storage, ...);
  7.     }
  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);
Advertisement
Add Comment
Please, Sign In to add comment