Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class UserController extends Zend_Controller_Action
- {
- protected $_cache;
- public function init()
- {
- $this->_cache = Zend_Cache('Core','File', array ('automatic_serialization' => true), array ('cache_dir' => APPLICATION_PATH . '/cache));
- }
- public function getUserAction()
- {
- $userId = $this->getRequest()->getParam('id', 0);
- if (!$user = $this->_cache->load('USER_FROM_DB_' . $userId)) {
- $user = new Application_Model_User();
- $userMapper = new Application_Model_UserMapper();
- $userMapper->find($user, $userId);
- $this->_cache->save($user, 'USER_FROM_DB_' . $userId);
- }
- // value of $user now is an Application_Model_User instance
- ...
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement