summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7baace0)
raw | patch | inline | side by side (parent: 7baace0)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 3 Sep 2007 12:27:05 +0000 (12:27 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 3 Sep 2007 12:27:05 +0000 (12:27 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7198 594d385d-05f5-0310-b6e9-bd551577e9d8
include/class_cache_handler.inc | [new file with mode: 0644] | patch | blob |
diff --git a/include/class_cache_handler.inc b/include/class_cache_handler.inc
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+
+class gosa_cache
+{
+ var $c_memcache = NULL;
+ var $b_connected= FALSE;
+
+ function __construct()
+ {
+ $this->connect();
+ }
+
+
+ function connect()
+ {
+ $this->close();
+ if(class_exists("Memcache")){
+ $this->c_memcache = new Memcache;
+ $res = $this->c_memcache->connect("localhost",11211);
+ if(!$res){
+ $this->b_connected = FALSE;
+ $this->c_memcache = NULL;
+ }else{
+ $this->b_connected = TRUE;
+ }
+ }
+ }
+
+ function close()
+ {
+ if($this->b_connected){
+ $this->c_memcache->close();
+ }
+ }
+
+
+ function save($key,$value)
+ {
+ if($this->b_connected){
+ $this->c_memcache->set($key,$value);
+ }
+ }
+
+ function load($key)
+ {
+ if($this->b_connected){
+ return($this->c_memcache->get($key));
+ }
+ }
+
+ function remove($key)
+ {
+ if($this->b_connected){
+ return($this->c_memcache->delete($key));
+ }
+ }
+
+ function get_server_status()
+ {
+ if($this->b_connected){
+ return($this->c_memcache->getStats());
+ }else{
+ return(FALSE);
+ }
+ }
+}
+
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>