Skip to content

Expiration date bug with sqlite driver #560

@wloske

Description

@wloske

Configuration:

PhpFastCache version: 6.0.8
PHP version: 7.0.6
Operating system: win

Issue description:

I think there's a severe error in expiration date handling somewhere. When I set my cacheTTL to 60 * 60 * 24 * 30 which is 30 days, everything works fine. However, when I ramp it up to 31 days, somehow the expiration date in the database is not correct anymore.

I am using the sqlite driver. For 30 days I get exp = 1518191956 but for 31 days I get exp = 3033878630.

When I dump the cacheItem object right after having set the TTL, it contains the right date. It also contains the right date, when having set the defaultTtl config value but still enters the wrong date into the database.

My code looks basically like this:

$config = array('storage'            => 'sqlite',
	          'htaccess'           => false,
	          'cacheFileExtension' => 'db',
	          'defaultTtl'         => 60 * 60 * 24 * 30,
	          'path'               => $cachePath);

CacheManager::setDefaultConfig($config);
$cache = CacheManager::getInstance("sqlite");

$cacheKey = 'TEST 1'; //increment here, we want only misses
$cacheItem = $cache->getItem($cacheKey);

var_dump($cacheItem);

$cacheValue = "TEST";

$cacheItem->set($cacheValue);
//$cacheItem->expiresAfter(60 * 60 * 24 * 30);

var_dump($cacheItem);

$cache->save($cacheItem);

$cacheContent = $cacheItem->get();
return $cacheContent;

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions