You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.3 KiB
52 lines
1.3 KiB
10 months ago
|
<?php
|
||
|
class LtCacheHandle
|
||
|
{
|
||
|
public $configHandle;
|
||
|
public $group;
|
||
|
public $node;
|
||
|
public $role = "master";
|
||
|
public $connectionManager;
|
||
|
public $connectionResource;
|
||
|
protected $connectionAdapter;
|
||
|
|
||
|
public function __construct()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public function init()
|
||
|
{
|
||
|
$this->connectionManager = new LtCacheConnectionManager;
|
||
|
$this->connectionManager->configHandle =$this->configHandle;
|
||
|
}
|
||
|
|
||
|
public function add($key, $value, $ttl = 0, $tableName)
|
||
|
{
|
||
|
$this->initConnection();
|
||
|
return $this->connectionAdapter->add($key, $value, $ttl, $tableName, $this->connectionResource);
|
||
|
}
|
||
|
|
||
|
public function del($key, $tableName)
|
||
|
{
|
||
|
$this->initConnection();
|
||
|
return $this->connectionAdapter->del($key, $tableName, $this->connectionResource);
|
||
|
}
|
||
|
|
||
|
public function get($key, $tableName)
|
||
|
{
|
||
|
$this->initConnection();
|
||
|
return $this->connectionAdapter->get($key, $tableName, $this->connectionResource);
|
||
|
}
|
||
|
|
||
|
public function update($key, $value, $ttl = 0, $tableName)
|
||
|
{
|
||
|
$this->initConnection();
|
||
|
return $this->connectionAdapter->update($key, $value, $ttl, $tableName, $this->connectionResource);
|
||
|
}
|
||
|
|
||
|
protected function initConnection()
|
||
|
{
|
||
|
$connectionInfo = $this->connectionManager->getConnection($this->group, $this->node, $this->role);
|
||
|
$this->connectionAdapter = $connectionInfo["connectionAdapter"];
|
||
|
$this->connectionResource = $connectionInfo["connectionResource"];
|
||
|
}
|
||
|
}
|