Jump to content

Cache method storeWithExpire doesn't return boolean


TSP

Recommended Posts

Hi, 

1) The method storeWithExpire in system/Data/Cache.php doesn't return any indication on whether the value was stored successfully. 

However, for example, the memcache class (system/Data/Cache/Memcache.php) does return a boolean value in the set-method, which is the method that is called within storeWithExpire in the \IPS\Data\Cache-class. The same seems to be the case in other cache-classes. 

Could you please return the value that the set()-method returns when it's called in storeWithExpire?

 

2) Also, the method storeWithExpire in Cache.php does this: 

<?php
		if ( $this->set( $key, $this->encode( $value ), $expire ) )
		{
			$this->_data[ $key ] = $value;
			$this->_exists[ $key ] = $key;
		}

But the same method in the Cache/None.php-class doesn't do the equivalent. 

 

<?php
	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()
			) );
		}
	}

Could you change the method storeWithExpire in None.php to also set $this->_data and $this->_exists. 

Link to comment
Share on other sites

  • 2 weeks later...
On 13/3/2018 at 3:05 PM, TSP said:

But the same method in the Cache/None.php-class doesn't do the equivalent. 

In any case you can check if value is stored with:

$return = NULL;
try
{
	$return = \IPS\Data\Cache::i()->getWithExpire( $key, TRUE );
}
catch( \OutOfRangeException $e ){}

only this method currently take care of values set with $fallback=TRUE

Link to comment
Share on other sites

20 minutes ago, BomAle said:

In any case you can check if value is stored with:


$return = NULL;
try
{
	$return = \IPS\Data\Cache::i()->getWithExpire( $key, TRUE );
}
catch( \OutOfRangeException $e ){}

only this method currently take care of values set with $fallback=TRUE

Yes, but that currently does an extra database-call because they don't set $this->_data and $this->_exists on save. Which is why I wouldn't want to do that. 

Link to comment
Share on other sites

Quote

Yes, but that currently does an extra database-call because they don't set $this->_data and $this->_exists on save. Which is why I wouldn't want to do that. 

I hope this fixed soon, I see this code on dispatcher front for ouput guest cache page.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...