aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/class/cache.php
diff options
context:
space:
mode:
authorroot2014-09-25 10:26:56 +0200
committerroot2014-09-25 10:26:56 +0200
commit2036626b560f22efd59673187a2de3b1319fcf8a (patch)
tree5180be078e3758b6fe3c37834cf6074c148394d1 /bootstrap/class/cache.php
parent7ea240aef9b75758d05cb5212ef7c99b47b4180b (diff)
downloadjungegemeinde-2036626b560f22efd59673187a2de3b1319fcf8a.tar.gz
version 4.0
Diffstat (limited to 'bootstrap/class/cache.php')
-rw-r--r--bootstrap/class/cache.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/bootstrap/class/cache.php b/bootstrap/class/cache.php
new file mode 100644
index 0000000..8005484
--- /dev/null
+++ b/bootstrap/class/cache.php
@@ -0,0 +1,69 @@
+<?php
+
+class cache {
+ public $token = "";
+
+ private $db;
+
+ public function __construct($rconnect, $rdb){
+ $this->db = new Redis();
+
+ try {
+ $this->db->connect($rconnect);
+ } catch (Exception $e) {
+ return $e->getMessage();
+ }
+ try {
+ $this->db->ping();
+ } catch (Exception $e) {
+ return $e->getMessage();
+ }
+ try {
+ $this->db->select($rdb);
+ } catch (Exception $e) {
+ return $e->getMessage();
+ }
+ }
+
+ public function check(){
+ try {
+ return $this->db->ping();
+ } catch (Exception $e) {
+ return $e->getMessage();
+ }
+ }
+
+ public function setKey($key, $value, $ttl = null){
+ $this->db->set($key, $value, $ttl);
+ }
+
+ public function getValue($key){
+ return $this->db->get($key);
+ }
+
+ public function getToken($data, $append = ""){
+ $this->token = CACHEPREFIX . $append . md5(strtolower($data));
+ return $this->token;
+ }
+
+ public function exists($key){
+ return $this->db->exists($key);
+ }
+
+ public function delete($key){
+ return $this->db->delete($key);
+ }
+
+ public function del($key){
+ return $this->db->delete($key);
+ }
+
+ public function flush($token = null){
+ if ( is_null($token) )
+ return $this->db->flushDB();
+ else
+ return $this->db->delete($token);
+ }
+}
+
+