Reduce the number of sessions between redis and php

Asked 1 years ago, Updated 1 years ago, 100 views

I'm using redis from php.

$redis=newRedis();
$redis->connect('127.0.0.1',6379);

When you session to redis, as shown in , the number of sessions increases each time the php program is read.In other words, running this php program on a heavily accessed site can exceed the system capacity.

I've also heard that Redis and php have a session and new requests will be made in the previous session.

What kind of implementation will it actually be?Or if you know any other methods, please let me know.

php redis

2022-09-29 22:06

1 Answers

I'm sorry if you're mistaken, but if you're using Ravel, why don't you use the Redis facade?

use Illuminate\Support\Facades\Redis;

For example, I think it can be used in the following places.

// key gets key value
$value = Redis::get('key');
// Set a value for the key with an expiration date of 10 seconds
Redis::setex('key',10,'value);


2022-09-29 22:06

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.