Is there any cross(-user)-session cache mechanism?
The problem is:
I've heard several bad things/posts about APC - so I'm putting it away. Let me know if you have any good argument to let re-consider it as an option.
MemCached looks a good alternative, since it looks like there's some sort of lib already implemented inside Zend to deal with it.
Basically, I'm concerned about reducing this sessionId requests.
Thanks a lot!
UPDATE
The answer bellow didn't actually solved the problem but comments did it. Zend_Cache (as mentioned by @Rijndael) is the solution to my situation. The final code should be very similar to this:
$frontendOptions = array(
'lifetime' => 7200, // cache lifetime of 2 hours
'automatic_serialization' => true
);
$backendOptions = array(
'cache_dir' => './tmp/' // Directory where to put the cache files
);
// getting a Zend_Cache_Core object
$cache = Zend_Cache::factory('Core',
'File',
$frontendOptions,
$backendOptions);
if( ($result = $cache->load('myresult')) === false ) {
// cache miss; connect to the database
$db = Zend_Db::factory( [...] );
$result = $db->fetchAll('SELECT * FROM huge_table');
$cache->save($result, 'myresult');
} else {
// cache hit! shout so that we know
echo "This one is from cache!
";
}
print_r($result);
http://framework.zend.com/manual/1.12/en/zend.cache.introduction.html
Not sure about the specifics of magento but as a ZF developer there are several ways you can approach this:
If by cross-session you are referring to an application that exists on the same server but under a different subdomain, you could do something like:
In application.ini:
session.domaincookie = .mysite.co.uk ;
Then in bootstrap,
Zend_Session::setOptions($this->getOption('session'));
The above approach will make session data visible across ALL subdomains.
If it is a 3rd party API then just store the sessionId in the local session:
$s = new Zend_Session_Namespace("user_session");
$s->session_id = $api->session_id;
$s->setExpirationSeconds(strtotime("+1 hour"));
Don't use APC, it is a deserted project. If you need memory caching, using Redis or Memcached. You can also use Zend_Cache.