View difference between Paste ID: yxw7U34n and Tm19g26U
SHOW: | | - or go back to the newest paste.
1
<?php
2
3
class UserController extends Zend_Controller_Action
4
{
5
    protected $_cache;
6
7
    public function init()
8
    {
9
        $this->_cache = Zend_Cache('Core','File', array ('automatic_serialization' => true), array ('cache_dir' => APPLICATION_PATH . '/cache));
10
    }
11
12-
    public function get-user()
12+
    public function getUserAction()
13
    {
14
         $userId = $this->getRequest()->getParam('id', 0);
15
         if (!$user = $this->_cache->load('USER_FROM_DB_' . $userId)) {
16
             $user = new Application_Model_User();
17
             $userMapper = new Application_Model_UserMapper();
18
             $userMapper->find($user, $userId);
19
             $this->_cache->save($user, 'USER_FROM_DB_' . $userId);
20
         }
21
         // value of $user now is an Application_Model_User instance
22
         ...
23
    }
24
}