Reputation: 483
I used the laravel's default Redis::set() function to store items, but I have 13k records and the memory usage is around 400mb. Now I'm looking for ways to reduce it. I noticed laravel stores data as string not as hash which is wasting resources. How can I use Redis with hash through laravel?
Upvotes: 1
Views: 9613
Reputation: 654
In the official Laravel Redis Facade, it's said that
The Redis facade supports dynamic methods, meaning you may call any Redis command on the facade and the command will be passed directly to Redis
So I guess you can use
Redis::hSet('h', 'key1', 'hello');
$value = Redis::hGet('h', 'key1');
But I really doubt that you will reduce drastically your memory usage, unless you have very long key name. Instead you can :
If you test, let us know your results, it can be interesting.
Upvotes: 3