Use microtime to have more precision on cache time
This commit is contained in:
parent
d592c14a6c
commit
4d16e30a16
@ -1,5 +1,11 @@
|
||||
# Upgrade to 2.5
|
||||
|
||||
## Minor BC BREAK: query cache key time is now a float
|
||||
|
||||
As of 2.5, the `QueryCacheEntry#time` property will contain a float value
|
||||
instead of an integer in order to have more precision and also to be consistent
|
||||
with the `TimestampCacheEntry#time`.
|
||||
|
||||
## Minor BC BREAK: discriminator map must now include all non-transient classes
|
||||
|
||||
It is now required that you declare the root of an inheritance in the
|
||||
|
@ -38,18 +38,18 @@ class QueryCacheEntry implements CacheEntry
|
||||
/**
|
||||
* READ-ONLY: Public only for performance reasons, it should be considered immutable.
|
||||
*
|
||||
* @var integer Time creation of this cache entry
|
||||
* @var float Time creation of this cache entry
|
||||
*/
|
||||
public $time;
|
||||
|
||||
/**
|
||||
* @param array $result
|
||||
* @param integer $time
|
||||
* @param float $time
|
||||
*/
|
||||
public function __construct($result, $time = null)
|
||||
{
|
||||
$this->result = $result;
|
||||
$this->time = $time ?: time();
|
||||
$this->time = $time ?: microtime(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,6 +35,6 @@ class TimestampQueryCacheValidator implements QueryCacheValidator
|
||||
return true;
|
||||
}
|
||||
|
||||
return ($entry->time + $key->lifetime) > time();
|
||||
return ($entry->time + $key->lifetime) > microtime(true);
|
||||
}
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ class DefaultQueryCacheTest extends OrmTestCase
|
||||
array('id'=>2, 'name' => 'Bar')
|
||||
);
|
||||
|
||||
$entry->time = time() - 100;
|
||||
$entry->time = microtime(true) - 100;
|
||||
|
||||
$this->region->addReturn('get', $entry);
|
||||
$this->region->addReturn('get', new EntityCacheEntry(Country::CLASSNAME, $entities[0]));
|
||||
|
Loading…
x
Reference in New Issue
Block a user