From 4f923b809b4e38e0639e253f428fb6c4df03ee67 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 27 Nov 2014 15:55:25 +0100 Subject: More structured + better UI --- linkshorter/class/db.php | 73 ------------------------------------------------ 1 file changed, 73 deletions(-) delete mode 100644 linkshorter/class/db.php (limited to 'linkshorter/class/db.php') diff --git a/linkshorter/class/db.php b/linkshorter/class/db.php deleted file mode 100644 index 7713487..0000000 --- a/linkshorter/class/db.php +++ /dev/null @@ -1,73 +0,0 @@ -db = new Redis(); - - if ( ! $connect || ! $db ) - return; - - $this->connect($connect, $db); - } - - public function connect($connect, $db){ - try { - $this->db->connect($connect); - } catch (Exception $e){ - $this->error = $e; - return false; - } - - try { - $this->db->select($db); - } catch (Exception $e){ - $this->error = $e; - return false; - } - - try { - $this->db->ping(); - } catch (Exception $e){ - $this->error = $e; - return false; - } - - return true; - } - - public function expire($key, $ttl){ - try { - $this->db->setTimeout($key, $ttl); - } catch (Exception $e){ - $this->error = $e; - return false; - } - } - - public function set($key, $value, $ttl = null){ - if ( is_null($ttl) ) - return $this->db->set($key, $value); - else - return $this->db->set($key, $value, (int)$ttl); - } - - public function get($key){ - return $this->db->get($key); - } - - public function exists($key){ - return $this->db->exists($key); - } - - public function __destruct(){ - try { - $this->db->close(); - } catch (Exception $e){ - return false; - } - } -} -- cgit v1.2.3