mstdmstd's avatar

How to read/write array data in redis with unknown prefix ?

In laravel app I need to save array of users on some page in Redis storage and I do :

$userId = $request->user()->id;
$page = $this->routeName;
$key = "{$page}:{$userId}";   // It has value : news-publisher-task-is-viewed-5:1

Redis::setex($key, 5, $userId);

But in I see in phpRedisAdmin :

https://img001.prntscr.com/file/img001/l8jZ-qE8QM-3Vniw9MzJTQ.png

What is "news_publisher_database_" prefix in in key storage ? It looks like based on APP_NAME var in my .env file, but

a) how can I control this prifix ? There could be several users on 1 page how to write/read them as I need to get array of users if several people on the same page. I try to read like :

	```
    $page = " news-publisher-task-is-viewed-5";

    $ret = collect(Redis::keys("{$page}:*"))
        ->map(function($key) use($page) {
            \Log::info(varDump($key, ' -1 INSIDE MAP $key::'));
    ```

// But checking value above I see array of

 [0] => news_publisher_database_1

b) That seems not valid value =- I need list of users on this page. How to make it ...

0 likes
0 replies

Please or to participate in this conversation.