Files
luos/workflow/engine/classes/class.fileCache.php

110 lines
2.6 KiB
PHP
Raw Normal View History

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
<?php
/**
* class.memcached.php
* @package workflow.engine.ProcessMaker
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
class FileCache {
function __construct($dir) {
$this->dir = $dir;
}
private function _name($key) {
return sprintf ( "%s/%s", $this->dir, sha1 ( $key ) );
}
public function get($key, $expiration = 3600) {
if (! is_dir ( $this->dir ) or ! is_writable ( $this->dir )) {
return FALSE;
}
$cache_path = $this->_name ( $key );
if (! @file_exists ( $cache_path )) {
return FALSE;
}
if (filemtime ( $cache_path ) < (time () - $expiration)) {
// $this->clear($key);
// different users can have different timeout requests
return FALSE;
}
if (! $fp = @fopen ( $cache_path, 'rb' )) {
return FALSE;
}
flock ( $fp, LOCK_SH );
$cache = '';
if (filesize ( $cache_path ) > 0) {
$cache = unserialize ( fread ( $fp, filesize ( $cache_path ) ) );
}
else {
$cache = NULL;
}
flock ( $fp, LOCK_UN );
fclose ( $fp );
return $cache;
}
public function set($key, $data) {
if (! is_dir ( $this->dir ) or ! is_writable ( $this->dir )) {
return FALSE;
}
$cache_path = $this->_name ( $key );
if (! $fp = fopen ( $cache_path, 'wb' )) {
return FALSE;
}
if (flock ( $fp, LOCK_EX )) {
fwrite ( $fp, serialize ( $data ) );
flock ( $fp, LOCK_UN );
}
else {
return FALSE;
}
fclose ( $fp );
@chmod ( $cache_path, 0777 );
return TRUE;
}
public function clear($key) {
$cache_path = $this->_name ( $key );
if (file_exists ( $cache_path )) {
unlink ( $cache_path );
return TRUE;
}
return FALSE;
}
}