0

I have stored some data using using Redis in my Laravel project. It used a foreach loop to store each array row, and then I used Redis Pipeline store the each row as well. pipeline example My question is: how do I use a foreach Loop to access all the data in Redis? My example just shows how to access one.

$devicename_for_single_key = Redis::get('device_name:12345');
MarieWeb
  • 331
  • 4
  • 10

2 Answers2

0

okay I think I found my answer for my Laravel project. this will return an array.

        $redis = Redis::connection();
        $allKeys = $redis->keys('*');
MarieWeb
  • 331
  • 4
  • 10
0

I discovered there were some limitations to using Redis pipelining. I decided to use Redis hash, which works so much better for my laravel project. It stores both a key and a value. Foreach loops are easy too.

       <?php
       Redis::hMset('stored_list:' . $store['ID'], [
                    'product_name' => $product_name,
                    'cost' => $cost   ]
                       );
                       ?>
MarieWeb
  • 331
  • 4
  • 10