I have a function in Laravel model and I need to check if my key ($key variable) exists in Redis, in other words I want to make a condition to not allow for duplicate results from redis. Here is my function. Any help is appreciated.
function
public static function cacheFields($fields)
{
foreach ($fields as $fieldname => $values) {
$key = static::$redisFieldKey.$fieldname; // here is that variable
Redis::pipeline(function ($pipe) use ($key, $values) {
foreach ($values as $value => $label) {
$pipe->hset($key, $value, $label);
}
});
}
}