CODE STYLE class.memcached.php
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.memcached.php
|
* class.memcached.php
|
||||||
|
*
|
||||||
* @package workflow.engine.ProcessMaker
|
* @package workflow.engine.ProcessMaker
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
@@ -30,7 +32,8 @@
|
|||||||
* @package workflow.engine.ProcessMaker
|
* @package workflow.engine.ProcessMaker
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class PMmemcached {
|
class PMmemcached
|
||||||
|
{
|
||||||
const ONE_MINUTE = 60;
|
const ONE_MINUTE = 60;
|
||||||
const ONE_HOUR = 3600;
|
const ONE_HOUR = 3600;
|
||||||
const TWO_HOURS = 7200;
|
const TWO_HOURS = 7200;
|
||||||
@@ -44,7 +47,8 @@ class PMmemcached {
|
|||||||
|
|
||||||
private static $instance = NULL;
|
private static $instance = NULL;
|
||||||
|
|
||||||
public function __construct($workspace) {
|
public function __construct ($workspace)
|
||||||
|
{
|
||||||
$this->enabled = MEMCACHED_ENABLED;
|
$this->enabled = MEMCACHED_ENABLED;
|
||||||
$this->connected = false;
|
$this->connected = false;
|
||||||
$this->workspace = $workspace;
|
$this->workspace = $workspace;
|
||||||
@@ -52,8 +56,7 @@ class PMmemcached {
|
|||||||
$this->mem = new Memcached();
|
$this->mem = new Memcached();
|
||||||
$this->class = 'Memcached';
|
$this->class = 'Memcached';
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (class_exists( 'Memcache' )) {
|
if (class_exists( 'Memcache' )) {
|
||||||
$this->mem = new Memcache();
|
$this->mem = new Memcache();
|
||||||
$this->class = 'Memcache';
|
$this->class = 'Memcache';
|
||||||
@@ -62,8 +65,7 @@ class PMmemcached {
|
|||||||
if ($this->connected) {
|
if ($this->connected) {
|
||||||
$this->version = $this->mem->getVersion();
|
$this->version = $this->mem->getVersion();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
G::Loadclass( 'fileCache' );
|
G::Loadclass( 'fileCache' );
|
||||||
// create cache folder
|
// create cache folder
|
||||||
$cacheFolder = PATH_DATA . "sites/" . $workspace . "/cachefiles/";
|
$cacheFolder = PATH_DATA . "sites/" . $workspace . "/cachefiles/";
|
||||||
@@ -91,22 +93,26 @@ class PMmemcached {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
public static function getSingleton($workspace) {
|
public static function getSingleton ($workspace)
|
||||||
|
{
|
||||||
if (! self::$instance instanceof self) {
|
if (! self::$instance instanceof self) {
|
||||||
self::$instance = new PMmemcached( $workspace );
|
self::$instance = new PMmemcached( $workspace );
|
||||||
}
|
}
|
||||||
return self::$instance;
|
return self::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __clone() {
|
public function __clone ()
|
||||||
|
{
|
||||||
throw new Exception( "Clone is not allowed." );
|
throw new Exception( "Clone is not allowed." );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __wakeup() {
|
public function __wakeup ()
|
||||||
|
{
|
||||||
throw new Exception( "Deserializing is not allowed." );
|
throw new Exception( "Deserializing is not allowed." );
|
||||||
}
|
}
|
||||||
|
|
||||||
function set($key, $object, $timeout = 0) {
|
function set ($key, $object, $timeout = 0)
|
||||||
|
{
|
||||||
if (! $this->connected)
|
if (! $this->connected)
|
||||||
return false;
|
return false;
|
||||||
if ($this->class != 'filecache')
|
if ($this->class != 'filecache')
|
||||||
@@ -115,43 +121,50 @@ class PMmemcached {
|
|||||||
$this->mem->set( $this->workspace . '_' . $key, $object );
|
$this->mem->set( $this->workspace . '_' . $key, $object );
|
||||||
}
|
}
|
||||||
|
|
||||||
function get($key) {
|
function get ($key)
|
||||||
|
{
|
||||||
if (! $this->connected)
|
if (! $this->connected)
|
||||||
return false;
|
return false;
|
||||||
return $this->mem->get( $this->workspace . '_' . $key );
|
return $this->mem->get( $this->workspace . '_' . $key );
|
||||||
}
|
}
|
||||||
|
|
||||||
function add($key, $value) {
|
function add ($key, $value)
|
||||||
|
{
|
||||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||||
return false;
|
return false;
|
||||||
return $this->mem->add( $this->workspace . '_' . $key, $value );
|
return $this->mem->add( $this->workspace . '_' . $key, $value );
|
||||||
}
|
}
|
||||||
|
|
||||||
function increment($key, $value) {
|
function increment ($key, $value)
|
||||||
|
{
|
||||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||||
return false;
|
return false;
|
||||||
return $this->mem->increment( $this->workspace . '_' . $key, $value );
|
return $this->mem->increment( $this->workspace . '_' . $key, $value );
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete($key) {
|
function delete ($key)
|
||||||
|
{
|
||||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||||
return false;
|
return false;
|
||||||
return $this->mem->delete( $this->workspace . '_' . $key );
|
return $this->mem->delete( $this->workspace . '_' . $key );
|
||||||
}
|
}
|
||||||
|
|
||||||
function flush() {
|
function flush ()
|
||||||
|
{
|
||||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||||
return false;
|
return false;
|
||||||
return $this->mem->flush();
|
return $this->mem->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStats() {
|
function getStats ()
|
||||||
|
{
|
||||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||||
return false;
|
return false;
|
||||||
return $status = $this->mem->getStats();
|
return $status = $this->mem->getStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
function printDetails() {
|
function printDetails ()
|
||||||
|
{
|
||||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||||
return false;
|
return false;
|
||||||
$status = $this->mem->getStats();
|
$status = $this->mem->getStats();
|
||||||
|
|||||||
Reference in New Issue
Block a user