Commit 7247d92b authored by Alex Ne's avatar Alex Ne

Кеширование.

parent 8ced1ffd
<?php <?php
namespace X\Memcache; namespace X\Cache;
class Cache extends \Memcache class Memcache extends \memcache
{ {
protected $compression = false; protected $compression = false;
protected $prefix; protected $prefix;
protected $connect = false; protected $mcache = false;
function __construct( $prefix, $host = "localhost", $port = 11211, $compression = false ) function __construct( $prefix, $host = "localhost", $port = 11211, $compression = false )
{ {
$this->prefix = $prefix; $this->prefix = $prefix;
$this->compression = $compression; $this->compression = $compression;
if( $this->connect($host,$port) ) $this->connect = true; $this->connect($host,$port);
} }
public function set( $key, $value, $expire = 240 ) public function set( $key, $value, $expire = 240 )
{ {
$key = $this->prefix ."-". $key; $key = $this->prefix . $key;
return parent::set( $key , $value, $this->compression, $expire); return parent::set( md5($key), $value, $this->compression, $expire);
} }
public function get($key) public function get($key)
{ {
$key = $this->prefix ."-". $key; $key = $this->prefix . $key;
return parent::get($key, $this->compression); return parent::get( md5($key), $this->compression);
} }
} }
?> ?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment