rss feed Twitter Page Facebook Page Github Page Stack Over Flow Page

Install SCache on Ubuntu with PHP

Recently, I was looking for a session manager tool (other than memcached and redis) to compare and compare benchmark. I found Scache.

Scache is high performance session manager for distributed web applications' session data. SCache provides both persistent and on-demand expiring key-value storage with structured filesystem-like keyspace for referencing the data.

After reading what they had to say, I got curious and decided to try it.

Install scache

The installation was easy on Ubuntu. I downloaded their .deb package and that was it.

If you are running a different *nix based OS, you can build it from source.

This comes with the default config but, of course, you can always change it:

sudo vi /etc/scache/scached.conf

and restart the service.

/etc/init.d/scached restart

Using scache with PHP

Then I created a simple PHP file to test it.

$SCache = scache_open('a_secret_key');
$key = 'abc';
$scachePath = 'key/' . $key;
$data = scache_get($SCache, $scachePath);
if(!$data) {
  $result = fetch_data($key); // function to fetch your data
  scache_set($SCache, $scachePath, $result);
}

Their complete tutorial is available at: http://scache.nanona.fi/tutorial.html.

You can also use scache as the session handler. Unfortunately scache session handler emulation is very poorly tested mostly due to scached original mission to provide more flexible replacement for session handler (handle with care).

; in php.ini
session.save_handler="scache"

; optionally set connection information
; scache.default_host="remote.host.org"