Pars
Pars

Reputation: 5262

Running out of memory while storing lots of data in redis

I'm trying to execute this query in PHP Redis (Predis):

for ($i=0; $i < 10000000; $i++) {
    $client->SADD('key:'.$i, $i);
}

This code takes a long time, but it shouldn't run out of memory, besides, I've edited my php.ini file and changed memory_limit to 5000M!

But, after that change, I'm still getting this error:

Fatal Error: Allowed memory size xxxxxxxxxxxx exhausted.

Upvotes: 0

Views: 1978

Answers (1)

guy_fawkes
guy_fawkes

Reputation: 965

Redis is a key value in memory store I.e it uses ram to store. You have changed the memory limit of php not of Redis. The sadd function is adding to the Redis. Try to find how Redis uses ram to store

Upvotes: 1

Related Questions