phplaravelrediscommandpredis

How can i solve " Predis\ClientException : Command 'EXiSTS' is not a registered Redis command. " error?


I use redis class in the my custom provider but doesn't work on the server .

There aren't any problems on the local but i didn't understand why it doesn't work on the server.

When i use artisan commands i get this error.

" Predis\ClientException : Command 'EXiSTS' is not a registered Redis command.

at /var/www/vhosts/website.com/laravel_folder/website/vendor/predis/predis/src/Profile/RedisProfile.php:88 84| { 85| $commandID = strtoupper($commandID); 86| 87| if (!isset($this->commands[$commandID])) {

88| throw new ClientException("Command '$commandID' is not a registered Redis command."); 89| } 90| 91| $commandClass = $this->commands[$commandID]; 92| $command = new $commandClass();

Exception trace:

1 Predis\Profile\RedisProfile::createCommand("EXiSTS") /var/www/vhosts/website.com/laravel_folder/website/vendor/predis/predis/src/Client.php:323

2 Predis\Client::createCommand("exists") /var/www/vhosts/website.com/laravel_folder/website/vendor/predis/predis/src/Client.php:314

Please use the argument -v to see more details. "

My code :

public function boot()
    {
        $redis = new Redis();

        if ( !$redis->exists('activity_of_week') ) {
            $redis->set('activity_of_week',serialize( Activity::ofWeek(10) ));
        }

        if ( !$redis->exists('popular_companies') ) {
            $redis->set('popular_companies',serialize( TopRateCompanies::sortBy()->take(10) ));
        }

        $activityOfWeeks = $redis->get('activity_of_week');
        $popularCompanies = $redis->get('popular_companies');

        $popular = new PopularCategory();
        $popularCategories = $popular->take(10);

        View::composer('frontend.layout.footer', function ($view) use ($activityOfWeeks, $popularCompanies, $popularCategories) {
            /**
             * @var ViewAlias $view
             */

             $keys = [  'email'         => 'contact-email',
                        'facebook'      => 'facebook',
                        'instagram'     => 'instagram',
                        'twitter'       => 'twitter',
                        'youtube'       => 'youtube',
                        'phone'         => 'contact-phone',
                    ];

            $info = array_map( [$this,'contactInfo'],$keys );

            $view->with('contact', $info)
                    ->with('activityOfWeeks', $activityOfWeeks)
                    ->with('popularCompanies', $popularCompanies)
                    ->with('popularCategories', $popularCategories);
        });
    }

    public function contactInfo($key)
    {
        return Settings::where('key',$key)->firstOrFail()->value;
    }

Help me please .


Solution

  • It is a locale issue. I believe you are using Turkish locale in your app. And that causes issues with strtoupper function.

    There is a similar issue you can take a look here: https://github.com/nrk/predis/issues/372

    As a solution, if it's acceptable in your case you can try to change the local. Or as suggested in the issue, you can use the Redis facade Laravel provides. Redis::EXISTS like so.