init(); return $GLOBALS['external_cache_object']->initialized; } /** * Retrieve a key from cache. For the Zend Platform, a maximum age of 5 minutes is assumed. * * @param String $key -- The item to retrieve. * @return The item unserialized */ function sugar_cache_retrieve($key) { if($GLOBALS['external_cache_checked'] == false) { check_cache(); } return $GLOBALS['external_cache_object']->get($key); } /** * Internal -- This function actually retrieves information from the caches. * It is a helper function that provides that actual cache API abstraction. * * @param unknown_type $key * @return unknown * @deprecated * @see sugar_cache_retrieve */ function external_cache_retrieve_helper($key) { if($GLOBALS['external_cache_checked'] == false) { check_cache(); } return sugar_cache_retrieve($key); } /** * Put a value in the cache under a key * * @param String $key -- Global namespace cache. Key for the data. * @param Serializable $value -- The value to store in the cache. */ function sugar_cache_put($key, $value) { if($GLOBALS['external_cache_checked'] == false) { check_cache(); } $GLOBALS['external_cache_object']->set($key, $value); } /** * Clear a key from the cache. This is used to invalidate a single key. * * @param String $key -- Key from global namespace */ function sugar_cache_clear($key) { if($GLOBALS['external_cache_checked'] == false) { check_cache(); } $GLOBALS['external_cache_object']->__unset($key); } /** * Turn off external caching for the rest of this round trip and for all round * trips for the next cache timeout. This function should be called when global arrays * are affected (studio, module loader, upgrade wizard, ... ) and it is not ok to * wait for the cache to expire in order to see the change. */ function sugar_cache_reset() { //@todo implement this in new code // Set a flag to clear the code. sugar_cache_put('EXTERNAL_CACHE_RESET', true); // Clear the local cache $GLOBALS['cache_local_store'] = array(); // Disable the external cache for the rest of the round trip $GLOBALS['external_cache_enabled'] = false; sugar_clean_opcodes(); } /** * Reset opcode cache if present */ function sugar_clean_opcodes() { if($GLOBALS['external_cache_checked'] == false) { check_cache(); } if($GLOBALS['external_cache_object']) { $GLOBALS['external_cache_object']->clean_opcodes(); } }