E
E
Evgeny Khripunov2018-07-29 14:41:29
Laravel
Evgeny Khripunov, 2018-07-29 14:41:29

Is it possible to store laravel passport tokens in redis/memcache?

The SPA application is configured to authenticate via laravel passport . A token is attached to each request and it is checked whether there is one in the database. Therefore, with each get / post request, a query is sent to the database of the following form:

select * from `oauth_access_tokens` where `id` = '6756c7ef9221d9b897c1980a84349618aefce2e44db6380756b839a19c54bc5a0a65be3cd2a6ac90' limit 1

Is it possible to store a given table in redis? Those. in laravel passport , first check if there is a token in redis , if not, then check in the database , and then add it to redis . I would like to reduce the load on the database in this way.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2018-07-29
@Sanasol

And how many unique users do you have knocking on the apishka?
Here the request is nowhere simpler, this change will not give anything at all.
Not to mention the fact that the database itself has its own cache, and it works fine for all queries out of the box.

V
Vadim, 2018-08-02
Schepotiev @avengerweb

Well, why are you, how many users do you have there or how many are expected? They took and did load testing, made sure that the database would work quickly and perfectly here, and you are doing other more important things. To put it simply, before you get an impact on speed from such a simple request, you will understand that the bottle-neck here is php, and you will go to think in the direction of load-balancing and distributed systems, but when you start to run into the database, here then it will be possible to think of replication.
caching in this case will not save you, you will duplicate the data in memory, MySQL can do this without your help, in the general case it makes no sense to cache for single sparse and simple queries.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question