Skip to content

Instantly share code, notes, and snippets.

@leonrenkema
Last active January 19, 2016 18:18
Show Gist options
  • Save leonrenkema/6004aa0ff750bb7fea89 to your computer and use it in GitHub Desktop.
Save leonrenkema/6004aa0ff750bb7fea89 to your computer and use it in GitHub Desktop.
<?php
abstract class CacheDriver {
private static $instance = NULL;
public static function getInstance()
{
$classname = get_called_class();
if (self::$instance != NULL) return self::$instance;
self::$instance = new $classname();
return self::$instance;
}
}
class MemcachedDriver extends CacheDriver {
}
$cacheDriver = MemcachedDriver::getInstance();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment