[eluser]RaZoR LeGaCy[/eluser]
Looking to move from using Zend Framework Memcache but need help with class.
I have models that use pre-existing code and need to stay that way. The old code uses Cache::init($lifetime of cache); so I need to keep it this way. Problem is, I cannot get the $_cache variable and the $lifetime variable into the save function.
I try $this-> and it says "Using $this when not in object context" and when using $lifetime, is says "Undefined variable: lifetime"; the same for $_cache
Code:
class Cache
{
public $_cache;
public $lifetime;
//static protected $_cache;
function init($lifetime=3600) {
$_cache = new Memcache;
$_cache->addServer('127.0.0.1', 11211);
}
static function getInstance() {
return self::$_cache;
}
static function save($key, $value) {
return $_cache->set($key, $value, 0, time()+$lifetime);
}
}
What is wrong here?