3

Across our application, we use subclasses of Zend_Db_Row to represent objects in our application. these objects are being returned by various fetch functions.

<?php
require_once 'Zend/Db.php';

class Model_Users extends Zend_Db_Table_Abstract
{
    protected $_name = 'users';
    protected $_primary = 'userId';
    protected $_rowClass = 'Model_User';

    /**
     * fetch user by email
     * 
     * @param string $email
     */
    public function fetchWithEmail($email)
    {
        $select = $this->select();
        $select->where('email = ?', $email);
        return $this->fetchRow($select);
    }

}

The issue is that we call the fetch functions multiple times (with the same values) from different functions, models, controllers and such. so for example, $modelUsers->fetchWithEmail('user@domain.com') appears 10 times in a single php script execution.

We are planning on using memcached for caching these objects, however, it would still call the cache server 10 times (instead of calling the database 10 times). using memcache will be faster, but we want to call the cache server only once (instead of 10 times)

Any framework / module of zend framework that can help us archive some kind of local cache? That if our script will call $modelUsers->fetchWithEmail('user@domain.com'), it would enter the script memory until the script execution was completed (or either an update or delete function changed the value of that row in the database)

aporat
  • 5,922
  • 5
  • 32
  • 54

2 Answers2

1

Doctrine ORM implements EntityManager.

The EntityManager API is used to manage the persistence of your objects and to query for persistent objects.

http://www.doctrine-project.org/docs/orm/2.1/en/reference/architecture.html#the-entitymanager

Alex
  • 1,712
  • 19
  • 16
  • I heard that from a co-worker as well and it does looks interesting, however our entire application is already based on Zend_Db. – aporat Dec 06 '11 at 21:34
1

Zend_Cache would work, and you could use Apc, Memcache, Flat files, etc.

Glen Solsberry
  • 11,960
  • 15
  • 69
  • 94