Lordi Uusipaavalniemi

Learn the sweetness of my mercy

Subscribe to RSS feed

Posts tagged with "development"

Quick and Dirty Caching for eZJSCore (eZ Publish)

, , , ...

eZJSCore is an extension for eZ Publish that aims to help developers in implementing backends for AJAXy interfaces. As of now (eZ Publish 4.2 and 4.3) the eZJSCore extension of does not support caching at all. Read more about using the extension at share.ez.no.

For some dynamic interfaces it makes sense to have caching for the AJAX calls. Since eZ Publish requires the eZ Components component library it is natural that we would use it for caching.

I built a quick and dirty caching method using the eZ Components Cache Component. At the moment it requires APC, but if you want to have a backup, just see the documentation at the documentation page. At the moment there is no automatic purging of cache on content publish, just a TTL of 60 seconds. This should be feasible to implement using a content edit handler.

Here's the code in all it's simplicity:


public static function get_node( $args ) {

	// set cache key
	$cache_key = 'ezjscore-get_node-';
	
	// add keys
	foreach($args as $arg){
		$cache_key .= $arg;
	}
	
	// set cache options
	$options = array(
	  'ttl'   => 60
	);
	
	// init cache
	ezcCacheManager::createCache( 'apc', 'apc', 'ezcCacheStorageApcPlain', $options );
	$cache = ezcCacheManager::getCache( 'apc' );
	
	// check if node is available in cache
	if ( ( $node = $cache->restore( $cache_key ) ) === false ){
		
		// fetch node and datamap
		$node = eZContentObjectTreeNode::fetch( $args[0] );
		$node->ContentObject->fetchDataMap();
		
		// store node to cache
		$cache->store( $cache_key, $node );  									
	
	}
	
	echo ezjscAjaxContent::nodeEncode($node);
}



If you're a finnish speaker and want to know more about eZ Publish, check out my quick introduction to eZ Publish in Finnish. Scheren für Linkshänder.

HipHop for PHP Compatibility Blog

, , ,

On February 2nd 2010 FaceBook announced that they’re open sourcing a novel method for accelerating PHP applications.

After the announcement had been I made I went domain shopping and got myself hiphopphp.org . Like for most of my domains I’ve really got no use for it (some collect Stamps, I collect Domains I suppose).

A few days after the announcement I got an idea that I’d set up a blog to announce what works with HipHop and what does not, providing tips on how to make a certain functionality work, etc. This means popular software such as WordPress, Drupal, eZ Publish, Vanilla Forum, Small Machines Forum and the likes that under certain conditions could really benefit from HipHop.

Read more at hiphopphp.org

CocoaMySQL Universal Binary

, , , ...

Every once in a while it's good to have a GUI client to access databases. I used CocoaMySQL for Mac OS X a few years ago, but the development has unfortunately frozen in 2003. While the functionality is still just fine it's really slow when using the official PPC binary faint

Fortunately there are unofficial universal binaries available. Download them from theonline.org. Oh and don't forget that you can access remote MySQL databases using SSH tunneling:

ssh -fNg -L 3307:127.0.0.1:3306 you@yourhost.com

Everybody loves dolphins, right?

Oaktree plugin for WordPress

, ,

I've been using WordPress for a while now. It's grown into a great tool with some great plugins. I've always felt the navigation functions are a bit lame though. So today I thought I'd give something back to the WordPress community:

Oaktree is a small plugin for WordPress that generates an automatic XHTML navigation structure (nested unordered lists) from your pages. There might be other similar plugins around, but feel free to give it a try. The plugin has functions for writing navigation and navigation crumbs.

More info on my site