Initial checkin

This commit is contained in:
genuineparts 2025-06-20 19:10:23 +02:00
commit d75eb444fc
4304 changed files with 369634 additions and 0 deletions

101
inc/cache.class.php Normal file
View file

@ -0,0 +1,101 @@
<?php
/**
* Project: beFramed
* File: /inc/cache.class.php
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://www.jaud.be
* @copyright 2025 becast.at
* @author Bernhard Jaud <bernhard at becast dot at>
* @package beFramed Core
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
*/
/*
Already defined by PHP. I'll leave it here for Info
define("LOG_EMERG", 0);
define("LOG_ALERT", 1);
define("LOG_CRIT", 2);
define("LOG_ERR", 3);
define("LOG_WARNING", 4);
define("LOG_INFO", 6);
define("LOG_DEBUG", 7);
*/
$module["cache"]["name"]="Cache Class";
$module["cache"]["ver"]="0.9.10";
class cache {
var $server;
var $prefix;
var $obj;
var $port;
var $exp;
/////////////////////////////////////////
// Module data
/////////////////////////////////////////
//
// __construct
//
// Buid logger
//
function __construct() {
global $config, $logger;
$this->server=$config['MEMCACHE_SERVER'];
$this->port=$config['MEMCACHE_PORT'];
$this->prefix=$config['MEMCACHE_PREFIX'];
$this->exp=$config['MEMCACHE_EXPIRATION'];
$this->obj = new Memcached($this->prefix);
$con = $this->connect($this->server,$this->port);
if(!$con){
return false;
}else{
return true;
}
}
public function connect($host , $port){
$servers = $this->obj->getServerList();
if(is_array($servers)) {
foreach ($servers as $server) {
if($server['host'] == $host and $server['port'] == $port){
return true;
} else {
return $this->obj->addServer($host , $port);
}
}
}
}
function __destruct() {
$this->obj->quit();
}
function set($key,$var,$expiration=null){
if($expriation=null){
$expriation=$this->exp;
}
$this->obj->set($this->prefix.$key,$var,$expiration);
}
function get($key){
return $this->obj->get($this->prefix.$key);
}
}
?>