Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: Stixlink
- * Date: 10.07.14
- * Time: 18:49
- */
- namespace wrappers;
- class SMemcache implements \interfaces\ICache {
- private $memcache;
- private $memcacheConnect;
- private $duration;
- private $compressed;
- /**
- * @param string $host
- * @param int $port
- * @param int $compressed
- */
- public function __construct($host = "127.0.0.1", $port = 11211, $compressed = 0) {
- $this->memcache = new \Memcache();
- $this->memcacheConnect = $this->memcache->connect($host, $port);
- $this->compressed = $compressed;
- }
- /**
- * @param array|string $key
- *
- * @return array|string
- */
- public function get($key) {
- return $this->memcache->get($key);
- }
- /**
- * @param string $key
- * @param mixed $value
- * @param int $duration
- *
- * @return bool
- */
- public function set($key, $value, $duration = 3600) {
- return $this->memcache->set($key, $value, $this->compressed, $duration);
- }
- /**
- * @param string $key
- *
- * @return bool
- */
- public function delete($key) {
- return $this->memcache->delete($key);
- }
- public function __destruct() {
- $this->memcache->close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement