Comments (7)
I think, with TTL equal 0 - TTL_EXPIRED it's correct behaviour. If you need TTL_INFINITY - just use NULL in Set method
from cache-db.
Configuration in /config/db.php
:
<?php
declare(strict_types=1);
use Psr\Container\ContainerInterface;
use Yiisoft\Cache\Db\DbCache;
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Pgsql\Connection;
/** @var array $params */
return [
DbCache::class => static function (ContainerInterface $container) {
return new DbCache($container->get(ConnectionInterface::class), 'test-table');
},
ConnectionInterface::class => [
'class' => Connection::class,
'__construct()' => [
'dsn' => 'pgsql:host=127.0.0.1;dbname=scrutinizer;port=5432',
],
'setUsername()' => ['scrutinizer'],
'setPassword()' => ['scrutinizer'],
],
];
from cache-db.
I think, with TTL equal 0 - TTL_EXPIRED it's correct behaviour. If you need TTL_INFINITY - just use NULL in Set method
I understood that. But is not logical for me. I see that INFINITY const = 0, i used 0 (like and yii2), and after i find method in source and reed it i see that it must be used null instead
from cache-db.
Creo que, con TTL igual a 0 - TTL_EXPIRED es un comportamiento correcto. Si necesita TTL_INFINITY, simplemente use NULL en el método Set
Lo entendí. Pero no es lógico para mí. Veo que INFINITY const = 0, usé 0 (like y yii2), y después de encontrar el método en source y reed it veo que debe usarse null en su lugar
If it is correct if you want the cache to be infinite, just don't set ttl, the package is still missing the documentation, soon we will do it completely.
from cache-db.
Configuration in
/config/db.php
:<?php declare(strict_types=1); use Psr\Container\ContainerInterface; use Yiisoft\Cache\Db\DbCache; use Yiisoft\Db\Connection\ConnectionInterface; use Yiisoft\Db\Pgsql\Connection; /** @var array $params */ return [ DbCache::class => static function (ContainerInterface $container) { return new DbCache($container->get(ConnectionInterface::class), 'test-table'); }, ConnectionInterface::class => [ 'class' => Connection::class, '__construct()' => [ 'dsn' => 'pgsql:host=127.0.0.1;dbname=scrutinizer;port=5432', ], 'setUsername()' => ['scrutinizer'], 'setPassword()' => ['scrutinizer'], ], ];
No, I try it few hours and now I have default config. But its work after I replace 0 with null )
from cache-db.
$dbCache->set('test', 'test-me', 0); //show null
$dbCache->set('test1', 'test-me-1'); //show test-me-1
$dbCache->set('test2', 'test-me-2', 3600); // show test-me-2
https://www.php-fig.org/psr/psr-16/
If a negative or zero TTL is provided, the item MUST be deleted from the cache if it exists, as it is expired already.
from cache-db.
$dbCache->set('test', 'test-me', 0); //show null $dbCache->set('test1', 'test-me-1'); //show test-me-1 $dbCache->set('test2', 'test-me-2', 3600); // show test-me-2
https://www.php-fig.org/psr/psr-16/
If a negative or zero TTL is provided, the item MUST be deleted from the cache if it exists, as it is expired already.
It's very confused - we have infinity constant with zero value. But for used they, we must pass null
from cache-db.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cache-db.