Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
+19
-18
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief APC Caching Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 17 Sept 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -30,7 +30,7 @@ class _Apc extends \IPS\Data\Cache
|
||||
*/
|
||||
public static function supported()
|
||||
{
|
||||
return function_exists('apc_fetch');
|
||||
return function_exists('apcu_fetch');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,27 +43,28 @@ class _Apc extends \IPS\Data\Cache
|
||||
{
|
||||
if( isset( $this->cache[ $key ] ) )
|
||||
{
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Get {$key} from APC (already loaded)", 'cache' );
|
||||
\IPS\Log::debug( "Get {$key} from APC (already loaded)", 'cache' );
|
||||
return $this->cache[ $key ];
|
||||
}
|
||||
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Get {$key} from APC", 'cache' );
|
||||
\IPS\Log::debug( "Get {$key} from APC", 'cache' );
|
||||
|
||||
$this->cache[ $key ] = apc_fetch( \IPS\SUITE_UNIQUE_KEY . '_' . $key );
|
||||
$this->cache[ $key ] = apcu_fetch( \IPS\SUITE_UNIQUE_KEY . '_' . $key );
|
||||
return $this->cache[ $key ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract Method: Set
|
||||
*
|
||||
* @param string $key Key
|
||||
* @param string $value Value
|
||||
* @param string $key Key
|
||||
* @param string $value Value
|
||||
* @para, \IPS\DateTime $expire Expreation time, or NULL for no expiration
|
||||
* @return bool
|
||||
*/
|
||||
protected function set( $key, $value )
|
||||
protected function set( $key, $value, \IPS\DateTime $expire = NULL )
|
||||
{
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Set {$key} in APC", 'cache' );
|
||||
return (bool) apc_store( \IPS\SUITE_UNIQUE_KEY . '_' . $key, $value );
|
||||
\IPS\Log::debug( "Set {$key} in APC", 'cache' );
|
||||
return (bool) apcu_store( \IPS\SUITE_UNIQUE_KEY . '_' . $key, $value, $expire ? ( $expire->getTimestamp() - time() ) : 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,13 +77,13 @@ class _Apc extends \IPS\Data\Cache
|
||||
{
|
||||
if( isset( $this->cache[ $key ] ) )
|
||||
{
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Check exists {$key} from APC (already loaded)", 'cache' );
|
||||
return TRUE;
|
||||
\IPS\Log::debug( "Check exists {$key} from APC (already loaded)", 'cache' );
|
||||
return ( $this->cache[ $key ] === FALSE ) ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Check exists {$key} from APC", 'cache' );
|
||||
\IPS\Log::debug( "Check exists {$key} from APC", 'cache' );
|
||||
|
||||
$result = apc_fetch( \IPS\SUITE_UNIQUE_KEY . '_' . $key, $exists );
|
||||
$result = apcu_fetch( \IPS\SUITE_UNIQUE_KEY . '_' . $key, $exists );
|
||||
if ( $exists )
|
||||
{
|
||||
$this->cache[ $key ] = $result;
|
||||
@@ -102,8 +103,8 @@ class _Apc extends \IPS\Data\Cache
|
||||
*/
|
||||
protected function delete( $key )
|
||||
{
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Delete {$key} from APC", 'cache' );
|
||||
return (bool) apc_delete( \IPS\SUITE_UNIQUE_KEY . '_' . $key );
|
||||
\IPS\Log::debug( "Delete {$key} from APC", 'cache' );
|
||||
return (bool) apcu_delete( \IPS\SUITE_UNIQUE_KEY . '_' . $key );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,6 +115,6 @@ class _Apc extends \IPS\Data\Cache
|
||||
public function clearAll()
|
||||
{
|
||||
parent::clearAll();
|
||||
apc_clear_cache();
|
||||
apcu_clear_cache();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Abstract Storage Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @since 07 May 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Data\Cache;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache Exception Class
|
||||
*/
|
||||
class _Exception extends \RuntimeException
|
||||
{
|
||||
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Memcache Cache Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 17 Sept 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -137,19 +137,35 @@ class _Memcache extends \IPS\Data\Cache
|
||||
/**
|
||||
* Abstract Method: Set
|
||||
*
|
||||
* @param string $key Key
|
||||
* @param string $value Value
|
||||
* @param string $key Key
|
||||
* @param string $value Value
|
||||
* @para, \IPS\DateTime $expire Expreation time, or NULL for no expiration
|
||||
* @return bool
|
||||
*/
|
||||
protected function set( $key, $value )
|
||||
protected function set( $key, $value, \IPS\DateTime $expire = NULL )
|
||||
{
|
||||
if ( in_array( $key, $this->doesNotExist ) )
|
||||
{
|
||||
unset( $this->doesNotExist[ array_search( $key, $this->doesNotExist ) ] );
|
||||
}
|
||||
$this->cache[ $key ] = $value;
|
||||
|
||||
return (bool) $this->link->set( \IPS\SUITE_UNIQUE_KEY . '_' . $key, $value );
|
||||
|
||||
if ( $this->link instanceof \Memcached )
|
||||
{
|
||||
$result = (bool) $this->link->set( \IPS\SUITE_UNIQUE_KEY . '_' . $key, $value, $expire ? $expire->getTimestamp() : 0 );
|
||||
if ( !$result )
|
||||
{
|
||||
$error = $this->link->getResultCode();
|
||||
/** will log the error code returned by memcached; lookup: http://php.net/manual/en/memcached.getresultcode.php */
|
||||
\IPS\Log::debug( 'error code ' . $error, 'memcached_set_error' );
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (bool) $this->link->set( \IPS\SUITE_UNIQUE_KEY . '_' . $key, $value, MEMCACHE_COMPRESSED, $expire ? $expire->getTimestamp() : 0 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Dummy Cache Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 17 Sept 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -103,6 +103,33 @@ class _None extends \IPS\Data\Cache
|
||||
throw new \RuntimeException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value using cache method if available or falling back to the database
|
||||
*
|
||||
* @param string $key Key
|
||||
* @param bool $fallback Use database if no caching method is available?
|
||||
* @return mixed
|
||||
* @throws \OutOfRangeException
|
||||
*/
|
||||
public function getWithExpire( $key, $fallback=FALSE )
|
||||
{
|
||||
if ( $fallback )
|
||||
{
|
||||
try
|
||||
{
|
||||
return json_decode( \IPS\Db::i()->select( 'cache_value', 'core_cache', array( 'cache_key=? AND cache_expire>?', $key, time() ) )->first(), TRUE );
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract Method: Set
|
||||
*
|
||||
@@ -115,6 +142,27 @@ class _None extends \IPS\Data\Cache
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store value using cache method if available or falling back to the database
|
||||
*
|
||||
* @param string $key Key
|
||||
* @param mixed $value Value
|
||||
* @param \IPS\DateTime $expire Expiration if using database
|
||||
* @param bool $fallback Use database if no caching method is available?
|
||||
* @return void
|
||||
*/
|
||||
public function storeWithExpire( $key, $value, \IPS\DateTime $expire, $fallback=FALSE )
|
||||
{
|
||||
if ( $fallback )
|
||||
{
|
||||
\IPS\Db::i()->replace( 'core_cache', array(
|
||||
'cache_key' => $key,
|
||||
'cache_value' => json_encode( $value ),
|
||||
'cache_expire' => $expire->getTimestamp()
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract Method: Exists?
|
||||
*
|
||||
|
||||
+145
-35
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Redis Cache Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 18 Oct 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -63,7 +63,17 @@ class _Redis extends \IPS\Data\Cache
|
||||
/**
|
||||
* @brief Connection resource
|
||||
*/
|
||||
protected $link = null;
|
||||
protected static $links = array();
|
||||
|
||||
/**
|
||||
* @brief Connection key
|
||||
*/
|
||||
protected $connectionKey = NULL;
|
||||
|
||||
/**
|
||||
* @brief Connection timeout - keep low or you negate the benefits of caching
|
||||
*/
|
||||
protected $timeout = 2;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -73,71 +83,140 @@ class _Redis extends \IPS\Data\Cache
|
||||
*/
|
||||
public function __construct( $configuration )
|
||||
{
|
||||
/* Figure out our connection key, as you could theoretically attempt to connect to more than one Redis server */
|
||||
$this->connectionKey = md5( $configuration['server'] . ':' . $configuration['port'] );
|
||||
|
||||
/* If we've already attempted to establish this link, just return now */
|
||||
if( isset( static::$links[ $this->connectionKey ] ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Connect to server */
|
||||
try
|
||||
{
|
||||
$this->link = new \Redis;
|
||||
static::$links[ $this->connectionKey ] = new \Redis;
|
||||
|
||||
if( $this->link->connect( $configuration['server'], $configuration['port'] ) === FALSE )
|
||||
if( static::$links[ $this->connectionKey ]->connect( $configuration['server'], $configuration['port'], $this->timeout ) === FALSE )
|
||||
{
|
||||
$this->link = NULL;
|
||||
$this->resetConnection();
|
||||
|
||||
throw new \RedisException;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( $configuration['password'] )
|
||||
{
|
||||
if( $this->link->auth( $configuration['password'] ) === FALSE )
|
||||
if( static::$links[ $this->connectionKey ]->auth( $configuration['password'] ) === FALSE )
|
||||
{
|
||||
$this->link = NULL;
|
||||
$this->resetConnection();
|
||||
|
||||
throw new \RedisException;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( $this->link !== NULL )
|
||||
if( static::$links[ $this->connectionKey ] !== NULL )
|
||||
{
|
||||
$this->link->setOption( \Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP );
|
||||
static::$links[ $this->connectionKey ]->setOption( \Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP );
|
||||
}
|
||||
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Connected to Redis", 'cache' );
|
||||
/* If connection times out, connect can return TRUE and we won't know until our next attempt to talk to the server,
|
||||
so we should ping now to verify we were able to connect successfully */
|
||||
static::$links[ $this->connectionKey ]->ping();
|
||||
|
||||
register_shutdown_function( function( $object ){
|
||||
try
|
||||
{
|
||||
if( isset( static::$links[ $object->connectionKey ] ) AND static::$links[ $object->connectionKey ] )
|
||||
{
|
||||
static::$links[ $object->connectionKey ]->close();
|
||||
unset( static::$links[ $object->connectionKey ] );
|
||||
}
|
||||
}
|
||||
catch( \RedisException $e ){}
|
||||
}, $this );
|
||||
|
||||
\IPS\Log::debug( "Connected to Redis", 'cache' );
|
||||
}
|
||||
catch( \RedisException $e )
|
||||
{
|
||||
$this->link = NULL;
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Connection to Redis failed", 'cache' );
|
||||
$this->resetConnection( $e );
|
||||
\IPS\Log::debug( "Connection to Redis failed", 'cache' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract Method: Get
|
||||
*
|
||||
* @param string $key Key
|
||||
* @return string Value from the _datastore
|
||||
* @param string $key
|
||||
* @return string|FALSE Value from the _datastore; FALSE if key doesn't exist
|
||||
*/
|
||||
protected function get( $key )
|
||||
{
|
||||
if( isset( $this->cache[ $key ] ) )
|
||||
{
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Get {$key} from Redis (already loaded)", 'cache' );
|
||||
\IPS\Log::debug( "Get {$key} from Redis (already loaded)", 'cache' );
|
||||
return $this->cache[ $key ];
|
||||
}
|
||||
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Get {$key} from Redis", 'cache' );
|
||||
if ( static::$links[ $this->connectionKey ] )
|
||||
{
|
||||
\IPS\Log::debug( "Get {$key} from Redis", 'cache' );
|
||||
|
||||
$this->cache[ $key ] = $this->link->get( \IPS\SUITE_UNIQUE_KEY . '_' . $key );
|
||||
return $this->cache[ $key ];
|
||||
try
|
||||
{
|
||||
$this->cache[ $key ] = static::$links[ $this->connectionKey ]->get( \IPS\SUITE_UNIQUE_KEY . '_' . $key );
|
||||
|
||||
return $this->cache[ $key ];
|
||||
}
|
||||
catch( \RedisException $e )
|
||||
{
|
||||
$this->resetConnection( $e );
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* No connection */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract Method: Set
|
||||
*
|
||||
* @param string $key Key
|
||||
* @param string $value Value
|
||||
* @param string $key Key
|
||||
* @param string $value Value
|
||||
* @param \IPS\DateTime $expire Expreation time, or NULL for no expiration
|
||||
* @return bool
|
||||
*/
|
||||
protected function set( $key, $value )
|
||||
protected function set( $key, $value, \IPS\DateTime $expire = NULL )
|
||||
{
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Set {$key} in Redis", 'cache' );
|
||||
return (bool) $this->link->set( \IPS\SUITE_UNIQUE_KEY . '_' . $key, $value );
|
||||
if ( static::$links[ $this->connectionKey ] )
|
||||
{
|
||||
\IPS\Log::debug( "Set {$key} in Redis", 'cache' );
|
||||
|
||||
try
|
||||
{
|
||||
if ( $expire )
|
||||
{
|
||||
return (bool) static::$links[ $this->connectionKey ]->setex( \IPS\SUITE_UNIQUE_KEY . '_' . $key, $expire->getTimestamp() - time(), $value );
|
||||
}
|
||||
else
|
||||
{
|
||||
return (bool) static::$links[ $this->connectionKey ]->set( \IPS\SUITE_UNIQUE_KEY . '_' . $key, $value );
|
||||
}
|
||||
}
|
||||
catch( \RedisException $e )
|
||||
{
|
||||
$this->resetConnection( $e );
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* No connection */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,11 +229,12 @@ class _Redis extends \IPS\Data\Cache
|
||||
{
|
||||
if( isset( $this->cache[ $key ] ) )
|
||||
{
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Check exists {$key} from Redis (already loaded)", 'cache' );
|
||||
return TRUE;
|
||||
\IPS\Log::debug( "Check exists {$key} from Redis (already loaded)", 'cache' );
|
||||
return ( $this->cache[ $key ] === FALSE ) ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Check exists {$key} from Redis", 'cache' );
|
||||
\IPS\Log::debug( "Check exists {$key} from Redis", 'cache' );
|
||||
|
||||
/* We do a get instead of an exists() check because it will cause the cache value to be fetched and cached inline, saving another call to the server */
|
||||
return ( $this->get( $key ) === FALSE ) ? FALSE : TRUE;
|
||||
}
|
||||
@@ -167,22 +247,52 @@ class _Redis extends \IPS\Data\Cache
|
||||
*/
|
||||
protected function delete( $key )
|
||||
{
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Delete {$key} from Redis", 'cache' );
|
||||
return (bool) $this->link->delete( \IPS\SUITE_UNIQUE_KEY . '_' . $key );
|
||||
if ( static::$links[ $this->connectionKey ] )
|
||||
{
|
||||
\IPS\Log::debug( "Delete {$key} from Redis", 'cache' );
|
||||
|
||||
try
|
||||
{
|
||||
return (bool) static::$links[ $this->connectionKey ]->delete( \IPS\SUITE_UNIQUE_KEY . '_' . $key );
|
||||
}
|
||||
catch( \RedisException $e )
|
||||
{
|
||||
$this->resetConnection( $e );
|
||||
}
|
||||
}
|
||||
|
||||
/* No connection */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
* Reset connection
|
||||
*
|
||||
* @param \RedisException|NULL If this was called as a result of an exception, log that to the debug log
|
||||
* @return void
|
||||
*/
|
||||
protected function resetConnection( \RedisException $e = NULL )
|
||||
{
|
||||
if ( $e !== NULL )
|
||||
{
|
||||
\IPS\Log::debug( $e, 'redis_exception' );
|
||||
}
|
||||
static::$links[ $this->connectionKey ] = NULL;
|
||||
throw new \IPS\Data\Cache\Exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract Method: Clear All Caches
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __destruct()
|
||||
public function clearAll()
|
||||
{
|
||||
if( $this->link )
|
||||
{
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Disconnect from Redis", 'cache' );
|
||||
parent::clearAll();
|
||||
|
||||
$this->link->close();
|
||||
if ( static::$links[ $this->connectionKey ] )
|
||||
{
|
||||
static::$links[ $this->connectionKey ]->flushDb();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Test Cache Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 7 Jan 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -74,11 +74,12 @@ class _Test extends \IPS\Data\Cache
|
||||
/**
|
||||
* Abstract Method: Set
|
||||
*
|
||||
* @param string $key Key
|
||||
* @param string $value Value
|
||||
* @param string $key Key
|
||||
* @param string $value Value
|
||||
* @para, \IPS\DateTime $expire Expreation time, or NULL for no expiration
|
||||
* @return bool
|
||||
*/
|
||||
protected function set( $key, $value )
|
||||
protected function set( $key, $value, \IPS\DateTime $expire = NULL )
|
||||
{
|
||||
$return = \file_put_contents( $this->_path . '/' . $key . '.txt', $value );
|
||||
chmod( $this->_path . '/' . $key . '.txt', \IPS\IPS_FILE_PERMISSION );
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Wincache Cache Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 17 Sept 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -43,11 +43,11 @@ class _Wincache extends \IPS\Data\Cache
|
||||
{
|
||||
if( isset( $this->cache[ $key ] ) )
|
||||
{
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Get {$key} from Wincache (already loaded)", 'cache' );
|
||||
\IPS\Log::debug( "Get {$key} from Wincache (already loaded)", 'cache' );
|
||||
return $this->cache[ $key ];
|
||||
}
|
||||
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Get {$key} from Wincache", 'cache' );
|
||||
\IPS\Log::debug( "Get {$key} from Wincache", 'cache' );
|
||||
|
||||
$this->cache[ $key ] = wincache_ucache_get( \IPS\SUITE_UNIQUE_KEY . '_' . $key );
|
||||
return $this->cache[ $key ];
|
||||
@@ -56,14 +56,15 @@ class _Wincache extends \IPS\Data\Cache
|
||||
/**
|
||||
* Abstract Method: Set
|
||||
*
|
||||
* @param string $key Key
|
||||
* @param string $value Value
|
||||
* @param string $key Key
|
||||
* @param string $value Value
|
||||
* @para, \IPS\DateTime $expire Expreation time, or NULL for no expiration
|
||||
* @return bool
|
||||
*/
|
||||
protected function set( $key, $value )
|
||||
protected function set( $key, $value, \IPS\DateTime $expire = NULL )
|
||||
{
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Set {$key} in Wincache", 'cache' );
|
||||
return (bool) wincache_ucache_set( \IPS\SUITE_UNIQUE_KEY . '_' . $key, $value );
|
||||
\IPS\Log::debug( "Set {$key} in Wincache", 'cache' );
|
||||
return (bool) wincache_ucache_set( \IPS\SUITE_UNIQUE_KEY . '_' . $key, $value, $expire ? ( $expire->getTimestamp() - time() ) : 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,11 +77,11 @@ class _Wincache extends \IPS\Data\Cache
|
||||
{
|
||||
if( isset( $this->cache[ $key ] ) )
|
||||
{
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Check exists {$key} from Wincache (already loaded)", 'cache' );
|
||||
return TRUE;
|
||||
\IPS\Log::debug( "Check exists {$key} from Wincache (already loaded)", 'cache' );
|
||||
return ( $this->cache[ $key ] === FALSE ) ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Check exists {$key} from Wincache", 'cache' );
|
||||
\IPS\Log::debug( "Check exists {$key} from Wincache", 'cache' );
|
||||
return wincache_ucache_exists( \IPS\SUITE_UNIQUE_KEY . '_' . $key );
|
||||
}
|
||||
|
||||
@@ -92,7 +93,7 @@ class _Wincache extends \IPS\Data\Cache
|
||||
*/
|
||||
protected function delete( $key )
|
||||
{
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Delete {$key} from Wincache", 'cache' );
|
||||
\IPS\Log::debug( "Delete {$key} from Wincache", 'cache' );
|
||||
|
||||
return (bool) wincache_ucache_delete( \IPS\SUITE_UNIQUE_KEY . '_' . $key );
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief XCache Cache Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 17 Sept 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -43,11 +43,11 @@ class _Xcache extends \IPS\Data\Cache
|
||||
{
|
||||
if( isset( $this->cache[ $key ] ) )
|
||||
{
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Get {$key} from Xcache (already loaded)", 'cache' );
|
||||
\IPS\Log::debug( "Get {$key} from Xcache (already loaded)", 'cache' );
|
||||
return $this->cache[ $key ];
|
||||
}
|
||||
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Get {$key} from Xcache", 'cache' );
|
||||
\IPS\Log::debug( "Get {$key} from Xcache", 'cache' );
|
||||
|
||||
$this->cache[ $key ] = xcache_get( \IPS\SUITE_UNIQUE_KEY . '_' . $key );
|
||||
return $this->cache[ $key ];
|
||||
@@ -56,14 +56,15 @@ class _Xcache extends \IPS\Data\Cache
|
||||
/**
|
||||
* Abstract Method: Set
|
||||
*
|
||||
* @param string $key Key
|
||||
* @param string $value Value
|
||||
* @param string $key Key
|
||||
* @param string $value Value
|
||||
* @para, \IPS\DateTime $expire Expreation time, or NULL for no expiration
|
||||
* @return bool
|
||||
*/
|
||||
protected function set( $key, $value )
|
||||
protected function set( $key, $value, \IPS\DateTime $expire = NULL )
|
||||
{
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Set {$key} in Xcache", 'cache' );
|
||||
return (bool) xcache_set( \IPS\SUITE_UNIQUE_KEY . '_' . $key, $value );
|
||||
\IPS\Log::debug( "Set {$key} in Xcache", 'cache' );
|
||||
return (bool) xcache_set( \IPS\SUITE_UNIQUE_KEY . '_' . $key, $value, $expire ? ( $expire->getTimestamp() - time() ) : 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,11 +77,11 @@ class _Xcache extends \IPS\Data\Cache
|
||||
{
|
||||
if( isset( $this->cache[ $key ] ) )
|
||||
{
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Check exists {$key} from Xcache (already loaded)", 'cache' );
|
||||
return TRUE;
|
||||
\IPS\Log::debug( "Check exists {$key} from Xcache (already loaded)", 'cache' );
|
||||
return ( $this->cache[ $key ] === FALSE OR $this->cache[ $key ] === NULL ) ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Check exists {$key} from Xcache", 'cache' );
|
||||
\IPS\Log::debug( "Check exists {$key} from Xcache", 'cache' );
|
||||
return xcache_isset( \IPS\SUITE_UNIQUE_KEY . '_' . $key );
|
||||
}
|
||||
|
||||
@@ -92,7 +93,7 @@ class _Xcache extends \IPS\Data\Cache
|
||||
*/
|
||||
protected function delete( $key )
|
||||
{
|
||||
\IPS\Log::i( LOG_DEBUG )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Delete {$key} from Xcache", 'cache' );
|
||||
\IPS\Log::debug( "Delete {$key} from Xcache", 'cache' );
|
||||
return (bool) xcache_unset( \IPS\SUITE_UNIQUE_KEY . '_' . $key );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user