PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Currency Performance Optimization

Zend_Currency's performance can be optimized using Zend_Cache. The static method Zend_Currency::setCache($cache) accepts one option: a Zend_Cache adapter. If the cache adapter is set, the localization data which is used by Zend_Currency will be cached. Additionally there are some static methods for manipulating the cache: getCache(), hasCache(), clearCache() and removeCache().

Example 163. Caching currencies

<?php
// creating a cache object
$cache Zend_Cache::factory('Core',
                             
'File',
                             array(
'lifetime' => 120,
                                   
'automatic_serialization' => true),
                             array(
'cache_dir'
                                       
=> dirname(__FILE__) . '/_files/'));
Zend_Currency::setCache($cache);

Zend Framework