Jwt-auth: No bug but Question for Laravel 5.8 -> cache ttl changed from minutes to seconds

Created on 1 Mar 2019  路  6Comments  路  Source: tymondesigns/jwt-auth

Hi,

with 5.8.:

https://laravel.com/docs/master/upgrade#cache-ttl-in-seconds

TTL in seconds

Likelihood Of Impact: Very High

In order to allow a more granular expiration time when storing items, the cache item time-to-live has changed from minutes to seconds. The put, putMany, add, remember and setDefaultCacheTime methods of the Illuminate\Cache\Repository class and its extended classes, as well as the put method of each cache store were updated with this changed behavior. See the related PR for more info.

If you are passing an integer to any of these methods, you should update your code to ensure you are now passing the number of seconds you wish the item to remain in the cache. Alternatively, you may pass a DateTime instance indicating when the item should expire:

// Laravel 5.7 - Store item for 30 minutes...
Cache::put('foo', 'bar', 30);

// Laravel 5.8 - Store item for 30 seconds...
Cache::put('foo', 'bar', 30);

// Laravel 5.7 / 5.8 - Store item for 30 seconds...
Cache::put('foo', 'bar', now()->addSeconds(30));

Has this any impact on:

wt-auth\src\Providers\Storage\Illuminate.php:
   14  use BadMethodCallException;
   15  use Tymon\JWTAuth\Contracts\Providers\Storage;
   16: use Psr\SimpleCache\CacheInterface as PsrCacheInterface;
   17: use Illuminate\Contracts\Cache\Repository as CacheContract;
   18  
   19  class Illuminate implements Storage
   20  {
   21      /**
   22:      * The cache repository contract.
   23       *
   24:      * @var \Illuminate\Contracts\Cache\Repository
   25       */
   26:     protected $cache;
   27  
   28      /**
   29:      * The used cache tag.
   30       *
   31       * @var string
   ..
   41       * Constructor.
   42       *
   43:      * @param  \Illuminate\Contracts\Cache\Repository  $cache
   44       *
   45       * @return void
   46       */
   47:     public function __construct(CacheContract $cache)
   48      {
   49:         $this->cache = $cache;
   50      }
   51  
   ..
   61      public function add($key, $value, $minutes)
   62      {
   63:         $this->cache()->put($key, $value, $minutes);
   64      }

?

Most helpful comment

All 6 comments

Yea I plan on adjusting the value dynamically, based on the laravel version, so it will be invisible to the user and always use minutes. This will be resolved when I officially tag the 5.8 compatibility version

sounds great, any timeline for this adjusting ?

Yea I plan on adjusting the value dynamically, based on the laravel version, so it will be invisible to the user and always use minutes. This will be resolved when I officially tag the 5.8 compatibility version

btw what's the stable version this package. "tymon/jwt-auth": "^1.0.0-rc.1" my composer.json is look like this, and that guy mention before about Cache class minutes to second. We still waiting stable version.

@tymondesigns A possible backwards compatible version is to use now()->addMinutes($minutes)

// Backwards compatible?
...put($key, $value, now()->addMinutes($minutes));

there was some commit progress in the last few days 馃憤

https://github.com/tymondesigns/jwt-auth/commit/9ec301bae5dd7f95f020860f5105346106eccb91

works with:

composer require tymon/jwt-auth:dev-develop#f72b8eb

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kofi1995 picture kofi1995  路  3Comments

agneshoving picture agneshoving  路  3Comments

johncloud200 picture johncloud200  路  3Comments

mihailo-misic picture mihailo-misic  路  3Comments

aofdev picture aofdev  路  3Comments