Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -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?
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user