2012-01-17 18:52:40 -04:00
|
|
|
<?php
|
|
|
|
|
|
2017-08-11 12:19:39 -04:00
|
|
|
class PMmemcached
|
2012-10-09 12:53:37 -04:00
|
|
|
{
|
|
|
|
|
const ONE_MINUTE = 60;
|
|
|
|
|
const ONE_HOUR = 3600;
|
|
|
|
|
const TWO_HOURS = 7200;
|
|
|
|
|
const EIGHT_HOURS = 28800;
|
|
|
|
|
|
|
|
|
|
var $version;
|
|
|
|
|
var $mem;
|
|
|
|
|
var $connected = false;
|
|
|
|
|
var $enabled = false;
|
|
|
|
|
var $supported = false;
|
|
|
|
|
|
2012-10-22 16:35:54 -04:00
|
|
|
private static $instance = null;
|
2012-10-09 12:53:37 -04:00
|
|
|
|
|
|
|
|
public function __construct ($workspace)
|
|
|
|
|
{
|
2016-09-09 11:09:02 -04:00
|
|
|
$this->enabled = defined("MEMCACHED_ENABLED") ? MEMCACHED_ENABLED : \G::$memcachedEnabled;
|
2012-10-09 12:53:37 -04:00
|
|
|
$this->connected = false;
|
|
|
|
|
$this->workspace = $workspace;
|
|
|
|
|
if (class_exists( 'Memcached' )) {
|
|
|
|
|
$this->mem = new Memcached();
|
|
|
|
|
$this->class = 'Memcached';
|
|
|
|
|
$this->connected = true;
|
|
|
|
|
} else {
|
|
|
|
|
if (class_exists( 'Memcache' )) {
|
|
|
|
|
$this->mem = new Memcache();
|
|
|
|
|
$this->class = 'Memcache';
|
|
|
|
|
$this->supported = true;
|
|
|
|
|
$this->connected = @$this->mem->connect( MEMCACHED_SERVER, 11211 );
|
|
|
|
|
if ($this->connected) {
|
|
|
|
|
$this->version = $this->mem->getVersion();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2012-12-13 11:58:34 -04:00
|
|
|
|
|
|
|
|
//Create cache folder
|
|
|
|
|
$cacheFolder = PATH_DATA . "sites". PATH_SEP . $workspace . PATH_SEP . "cachefiles" . PATH_SEP;
|
|
|
|
|
|
2012-10-09 12:53:37 -04:00
|
|
|
if (! file_exists( $cacheFolder )) {
|
|
|
|
|
if (! mkdir( $cacheFolder )) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->class = 'fileCache';
|
|
|
|
|
$this->connected = true;
|
|
|
|
|
$this->mem = new FileCache( $cacheFolder );
|
|
|
|
|
}
|
BUG 0000 herbert> SOLR implementation in PMOS2
Solr support in PMOS2 includes:
Functionality:
- Implementation of Home views (Inbox, Draft, Participated, Unassigned). The views return fast results.
- Include read, unread, all, and process filter in inbox View.
- Include process filter in draft view.
- Include started by me, completed by me, all, process, and status filter in participated view.
- Include process filter in unassigned view.
- Improved search functionality (search in user defined variables): Use the following syntax to search in process (user defined) variables. {variable_name}:{search_word} ex1:"causal:20*" where causal is the variable defined by the user.
+ Use of wildcards in search: Use * as wildcard at the begin or end of word
+ Multiple conditions in search: Separate multiple conditions by space ex2:"Materiales causal:20*" means that we are searching for the word Materiales and the causal that begin with 20.
+ Search in dates (interval ): Format=> {variable_date}:[yyyy-mm-dd TO yyyy-mm-dd]
Local date not UTC date required
ex: FechaRegistro:[2011-04-15 TO 2011-04-30] //registros con fecha entre el 2011-04-15 y el 2011-04-30.
+ we can use the wildcard *:
ex: FechaRegistro:[* TO 2011-04-30] //registros con fecha menor o igual a 2011-04-30.
FechaRegistro:[2011-04-15 TO *] //registros con fecha mayor o igual a 2011-04-15.
+ Search of exact phrases. format: {variable}:"frase a buscar"
ex: Cliente:"Jesus Marin"
- Application update function.
+ The function is called every time a change is detected in the application's data including the related delegations.
- Use of cache to improve performance
Not included:
- Order of task, sent by, and due date columns.
Pending:
- Advanced search view using faceted lists.
2012-05-15 10:56:48 -04:00
|
|
|
}
|
2012-10-09 12:53:37 -04:00
|
|
|
|
2016-09-09 11:09:02 -04:00
|
|
|
if (!$this->enabled) {
|
2012-10-09 12:53:37 -04:00
|
|
|
$this->connected = false;
|
BUG 0000 herbert> SOLR implementation in PMOS2
Solr support in PMOS2 includes:
Functionality:
- Implementation of Home views (Inbox, Draft, Participated, Unassigned). The views return fast results.
- Include read, unread, all, and process filter in inbox View.
- Include process filter in draft view.
- Include started by me, completed by me, all, process, and status filter in participated view.
- Include process filter in unassigned view.
- Improved search functionality (search in user defined variables): Use the following syntax to search in process (user defined) variables. {variable_name}:{search_word} ex1:"causal:20*" where causal is the variable defined by the user.
+ Use of wildcards in search: Use * as wildcard at the begin or end of word
+ Multiple conditions in search: Separate multiple conditions by space ex2:"Materiales causal:20*" means that we are searching for the word Materiales and the causal that begin with 20.
+ Search in dates (interval ): Format=> {variable_date}:[yyyy-mm-dd TO yyyy-mm-dd]
Local date not UTC date required
ex: FechaRegistro:[2011-04-15 TO 2011-04-30] //registros con fecha entre el 2011-04-15 y el 2011-04-30.
+ we can use the wildcard *:
ex: FechaRegistro:[* TO 2011-04-30] //registros con fecha menor o igual a 2011-04-30.
FechaRegistro:[2011-04-15 TO *] //registros con fecha mayor o igual a 2011-04-15.
+ Search of exact phrases. format: {variable}:"frase a buscar"
ex: Cliente:"Jesus Marin"
- Application update function.
+ The function is called every time a change is detected in the application's data including the related delegations.
- Use of cache to improve performance
Not included:
- Order of task, sent by, and due date columns.
Pending:
- Advanced search view using faceted lists.
2012-05-15 10:56:48 -04:00
|
|
|
return false;
|
2012-01-17 18:52:40 -04:00
|
|
|
}
|
2012-10-09 12:53:37 -04:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* to get singleton instance
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @return object
|
|
|
|
|
*/
|
|
|
|
|
public static function getSingleton ($workspace)
|
|
|
|
|
{
|
|
|
|
|
if (! self::$instance instanceof self) {
|
|
|
|
|
self::$instance = new PMmemcached( $workspace );
|
|
|
|
|
}
|
|
|
|
|
return self::$instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function __clone ()
|
|
|
|
|
{
|
|
|
|
|
throw new Exception( "Clone is not allowed." );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function __wakeup ()
|
|
|
|
|
{
|
|
|
|
|
throw new Exception( "Deserializing is not allowed." );
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-22 16:35:54 -04:00
|
|
|
public function set ($key, $object, $timeout = 0)
|
2012-10-09 12:53:37 -04:00
|
|
|
{
|
2012-10-22 16:35:54 -04:00
|
|
|
if (! $this->connected) {
|
2012-10-09 12:53:37 -04:00
|
|
|
return false;
|
2012-10-22 16:35:54 -04:00
|
|
|
}
|
2012-12-13 11:58:34 -04:00
|
|
|
|
|
|
|
|
if ($this->class != "fileCache") {
|
2012-10-09 12:53:37 -04:00
|
|
|
$this->mem->set( $this->workspace . '_' . $key, $object, false, $timeout );
|
2012-10-22 16:35:54 -04:00
|
|
|
} else {
|
2012-10-09 12:53:37 -04:00
|
|
|
$this->mem->set( $this->workspace . '_' . $key, $object );
|
2012-10-22 16:35:54 -04:00
|
|
|
}
|
2012-10-09 12:53:37 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-22 16:35:54 -04:00
|
|
|
public function get ($key)
|
2012-10-09 12:53:37 -04:00
|
|
|
{
|
2012-10-22 16:35:54 -04:00
|
|
|
if (! $this->connected) {
|
2012-10-09 12:53:37 -04:00
|
|
|
return false;
|
2012-10-22 16:35:54 -04:00
|
|
|
}
|
2012-10-09 12:53:37 -04:00
|
|
|
return $this->mem->get( $this->workspace . '_' . $key );
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-22 16:35:54 -04:00
|
|
|
public function add ($key, $value)
|
2012-10-09 12:53:37 -04:00
|
|
|
{
|
2012-12-13 11:58:34 -04:00
|
|
|
if (!$this->connected || $this->class == "fileCache") {
|
2012-10-09 12:53:37 -04:00
|
|
|
return false;
|
2012-10-22 16:35:54 -04:00
|
|
|
}
|
2012-12-13 11:58:34 -04:00
|
|
|
|
2012-10-09 12:53:37 -04:00
|
|
|
return $this->mem->add( $this->workspace . '_' . $key, $value );
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-22 16:35:54 -04:00
|
|
|
public function increment ($key, $value)
|
2012-10-09 12:53:37 -04:00
|
|
|
{
|
2012-12-13 11:58:34 -04:00
|
|
|
if (!$this->connected || $this->class == "fileCache") {
|
2012-10-09 12:53:37 -04:00
|
|
|
return false;
|
2012-10-22 16:35:54 -04:00
|
|
|
}
|
2012-12-13 11:58:34 -04:00
|
|
|
|
2012-10-09 12:53:37 -04:00
|
|
|
return $this->mem->increment( $this->workspace . '_' . $key, $value );
|
2012-01-17 18:52:40 -04:00
|
|
|
}
|
2012-07-12 20:36:41 -04:00
|
|
|
|
2012-12-13 11:58:34 -04:00
|
|
|
public function delete($key)
|
2012-10-09 12:53:37 -04:00
|
|
|
{
|
2013-06-05 12:28:48 -04:00
|
|
|
if (! $this->connected || $this->class == 'filecache') {
|
2012-10-09 12:53:37 -04:00
|
|
|
return false;
|
2012-10-22 16:35:54 -04:00
|
|
|
}
|
2012-12-13 11:58:34 -04:00
|
|
|
|
|
|
|
|
return $this->mem->delete($this->workspace . "_" . $key);
|
2012-10-09 12:53:37 -04:00
|
|
|
}
|
|
|
|
|
|
2012-12-13 11:58:34 -04:00
|
|
|
public function flush()
|
2012-10-09 12:53:37 -04:00
|
|
|
{
|
2013-06-05 12:28:48 -04:00
|
|
|
if (! $this->connected || $this->class == 'filecache') {
|
2012-10-09 12:53:37 -04:00
|
|
|
return false;
|
2012-10-22 16:35:54 -04:00
|
|
|
}
|
2012-12-13 11:58:34 -04:00
|
|
|
|
2012-10-09 12:53:37 -04:00
|
|
|
return $this->mem->flush();
|
2012-01-17 18:52:40 -04:00
|
|
|
}
|
2012-07-12 20:36:41 -04:00
|
|
|
|
2012-12-13 11:58:34 -04:00
|
|
|
public function getStats()
|
2012-10-09 12:53:37 -04:00
|
|
|
{
|
2013-06-05 12:28:48 -04:00
|
|
|
if (! $this->connected || $this->class == 'filecache') {
|
2012-10-09 12:53:37 -04:00
|
|
|
return false;
|
2012-10-22 16:35:54 -04:00
|
|
|
}
|
2012-12-13 11:58:34 -04:00
|
|
|
|
2012-10-09 12:53:37 -04:00
|
|
|
return $status = $this->mem->getStats();
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-13 11:58:34 -04:00
|
|
|
public function printDetails()
|
2012-10-09 12:53:37 -04:00
|
|
|
{
|
2013-06-05 12:28:48 -04:00
|
|
|
if (! $this->connected || $this->class == 'filecache') {
|
2012-10-09 12:53:37 -04:00
|
|
|
return false;
|
2012-10-22 16:35:54 -04:00
|
|
|
}
|
2012-12-13 11:58:34 -04:00
|
|
|
|
2012-10-09 12:53:37 -04:00
|
|
|
$status = $this->mem->getStats();
|
2012-12-13 11:58:34 -04:00
|
|
|
|
2013-06-05 12:28:48 -04:00
|
|
|
if (! is_array($status)) {
|
2012-12-13 11:58:34 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-09 12:53:37 -04:00
|
|
|
echo "<table border='1'>";
|
|
|
|
|
echo "<tr><td>Memcache Server version:</td><td> " . $status["version"] . "</td></tr>";
|
|
|
|
|
echo "<tr><td>Number of hours this server has been running </td><td>" . ($status["uptime"] / 3660) . "</td></tr>";
|
|
|
|
|
echo "<tr><td>Total number of items stored by this server ever since it started </td><td>" . $status["total_items"] . "</td></tr>";
|
|
|
|
|
echo "<tr><td>Number of open connections </td><td>" . $status["curr_connections"] . "</td></tr>";
|
|
|
|
|
echo "<tr><td>Total number of connections opened since the server started running </td><td>" . $status["total_connections"] . "</td></tr>";
|
|
|
|
|
echo "<tr><td>Number of connection structures allocated by the server </td><td>" . $status["connection_structures"] . "</td></tr>";
|
|
|
|
|
echo "<tr><td>Cumulative number of retrieval requests </td><td>" . $status["cmd_get"] . "</td></tr>";
|
|
|
|
|
echo "<tr><td> Cumulative number of storage requests </td><td>" . $status["cmd_set"] . "</td></tr>";
|
|
|
|
|
|
|
|
|
|
$percCacheHit = ((real) $status["get_hits"] / (real) $status["cmd_get"] * 100);
|
|
|
|
|
$percCacheHit = round( $percCacheHit, 3 );
|
|
|
|
|
$percCacheMiss = 100 - $percCacheHit;
|
|
|
|
|
|
|
|
|
|
echo "<tr><td>Number of keys that have been requested and found present </td><td>" . $status["get_hits"] . " ($percCacheHit%)</td></tr>";
|
|
|
|
|
echo "<tr><td>Number of items that have been requested and not found </td><td>" . $status["get_misses"] . "($percCacheMiss%)</td></tr>";
|
|
|
|
|
|
|
|
|
|
$MBRead = (real) $status["bytes_read"] / (1024 * 1024);
|
|
|
|
|
|
|
|
|
|
echo "<tr><td>Total number of bytes read by this server from network </td><td>" . $MBRead . " Mega Bytes</td></tr>";
|
|
|
|
|
$MBWrite = (real) $status["bytes_written"] / (1024 * 1024);
|
|
|
|
|
echo "<tr><td>Total number of bytes sent by this server to network </td><td>" . $MBWrite . " Mega Bytes</td></tr>";
|
|
|
|
|
$MBSize = (real) $status["limit_maxbytes"] / (1024 * 1024);
|
|
|
|
|
echo "<tr><td>Number of bytes this server is allowed to use for storage.</td><td>" . $MBSize . " Mega Bytes</td></tr>";
|
|
|
|
|
echo "<tr><td>Number of valid items removed from cache to free memory for new items.</td><td>" . $status["evictions"] . "</td></tr>";
|
|
|
|
|
echo "</table>";
|
2012-01-17 18:52:40 -04:00
|
|
|
}
|
BUG 0000 herbert> SOLR implementation in PMOS2
Solr support in PMOS2 includes:
Functionality:
- Implementation of Home views (Inbox, Draft, Participated, Unassigned). The views return fast results.
- Include read, unread, all, and process filter in inbox View.
- Include process filter in draft view.
- Include started by me, completed by me, all, process, and status filter in participated view.
- Include process filter in unassigned view.
- Improved search functionality (search in user defined variables): Use the following syntax to search in process (user defined) variables. {variable_name}:{search_word} ex1:"causal:20*" where causal is the variable defined by the user.
+ Use of wildcards in search: Use * as wildcard at the begin or end of word
+ Multiple conditions in search: Separate multiple conditions by space ex2:"Materiales causal:20*" means that we are searching for the word Materiales and the causal that begin with 20.
+ Search in dates (interval ): Format=> {variable_date}:[yyyy-mm-dd TO yyyy-mm-dd]
Local date not UTC date required
ex: FechaRegistro:[2011-04-15 TO 2011-04-30] //registros con fecha entre el 2011-04-15 y el 2011-04-30.
+ we can use the wildcard *:
ex: FechaRegistro:[* TO 2011-04-30] //registros con fecha menor o igual a 2011-04-30.
FechaRegistro:[2011-04-15 TO *] //registros con fecha mayor o igual a 2011-04-15.
+ Search of exact phrases. format: {variable}:"frase a buscar"
ex: Cliente:"Jesus Marin"
- Application update function.
+ The function is called every time a change is detected in the application's data including the related delegations.
- Use of cache to improve performance
Not included:
- Order of task, sent by, and due date columns.
Pending:
- Advanced search view using faceted lists.
2012-05-15 10:56:48 -04:00
|
|
|
}
|