Support the ongoing development of Laravel.io →
Session Cache
Last updated 1 year ago.
0

This sounds like a good use-case for using the cache. I'd create a SecurityTokenService class with a single getToken method. This method would do the following:

  1. Check the cache for an existing token (which will automatically be false if the expiration time has passed)

  2. If no token is found, generate a new token and store it in the cache

  3. Return the token

The only downside is that the token will be reset whenever you use the cache:clear command.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.