Questions tagged [predis]

Predis is a flexible and feature-complete PHP client library for the Redis key-value store.

Predis requires PHP >= 5.3 and it is entirely written in PHP.

It can be used without the need to build and install a native extension for the interpreter, making it also easier and faster to add new features which is great given how fast the development of Redis proceeds.

Speed up Predis

  • support HHVM >= 2.4.0
  • can be paired with a C extension phpiredis

Frameworks integration

Useful links

254 questions
6
votes
3 answers

Predis - how to use array with zadd function?

I've just started using Predis for Redis migration and I'm having trouble getting the zadd function to work with an array. This code works: foreach ($userIndexArr as $row) { $usernames[] = 0; $usernames[] = $row['username']; $result =…
jt_dylan
  • 71
  • 1
  • 6
5
votes
3 answers

Why isn't my PHPUnit mock of the Predis Client matching my expectations?

I'm trying to mock out the Predis client in a PHPUnit test. When I call the method I've tried to mock out, at the end of the test PHPUnit is telling me that the expectation was not met. Here's a code sample that reproduces my problem: class…
Tom Martin
  • 2,498
  • 3
  • 29
  • 37
5
votes
2 answers

Laravel 5.5 Redis problem - Call to undefined method Illuminate\Support\Facades\Redis::connect()

I moved my Laravel 5.5 application to another server - I use exactly the same code there (did a git clone) with exactly the same composer.json and composer.lock files (even the NGINX configuration is the same). When I run my application I get the…
manifestor
  • 1,352
  • 6
  • 19
  • 34
5
votes
2 answers

How to Install Redis on shared hosting?

I am developing a Laravel project and I'm using Predis for caching database queries. Now I have to install Redis on my server. Is it possible to install Redis on shared hosting?
leo
  • 109
  • 1
  • 2
  • 8
5
votes
1 answer

Remove All Keys from Redis in PHP

I was able to flash all keys from terminal using redis-cli flushdb. I have been searching for a while, took me an hour in order to find the simple command to do it in php. I didn't find it on stackoverflow so I wanted to post it to save someone…
Onix
  • 2,129
  • 2
  • 17
  • 26
5
votes
1 answer

Redis - Check if key exists using predis

Using predis is it possible to check if a key exists? My users data is stored as follows: public function createUser($email, $password, $username) { return $this->predis->hMset("user:{$username}", [ 'email' => $email, 'password'…
BugHunterUK
  • 8,346
  • 16
  • 65
  • 121
5
votes
2 answers

PHP Predis: how to get/delete keys containing special characters?

I need to delete a key containing some special keys (in my case square brackets): I do the following, but it does not work: $this->redis; $keys = $this->redis->keys("*"); foreach ($keys as $key) { // keys are in the following format: …
fdellutri
  • 963
  • 1
  • 7
  • 16
5
votes
3 answers

can predis hmget use array as parameter of multiple fields

can predis use array as 2nd parameter of hmget() to retrieve multiple fields on one go? e.g. $client->hmget($key, $fields); //$fields is an array Can it also accept many parameters of string as fields? e.g.: $client->hmget($key, $field1, $field2,…
Will-i-Am-Davidon
  • 1,532
  • 1
  • 14
  • 15
5
votes
1 answer

Predis timeout with high traffic site

Im running a website with high traffic peaks (around 10k online users) and Im facing this error with Predis when the site exceeds around 7k online users: PHP Fatal error: Uncaught exception 'Predis\\Connection\\ConnectionException' with message…
4
votes
5 answers

Trouble loading predis on php website

Answer: I had to change the path of PREDIS_BASE_PATH to predis/lib/. I want to load predis inside of a PHP file, but I am having trouble. I am following the guide to load predis on the predis github website (https://github.com/nrk/predis). Here is…
egidra
  • 347
  • 2
  • 9
  • 18
4
votes
1 answer

How to instruct predis to continue on error

In case of Redis failure, is that possible to instruct php predis (https://github.com/nrk/predis) to continue and to not die? I have Redis to handle application cache, but the application can run without cache, it just hits the database heavier. I…
AFRC
  • 902
  • 3
  • 9
  • 27
4
votes
3 answers

Displaying a large amount of data in paging table without heavily impacting DB

The current implementation is a single complex query with multiple joins and temporary tables, but is putting too much stress on my MySQL and is taking upwards of 30+ seconds to load the table. The data is retrieved by PHP via a JavaScript Ajax call…
DemonGyro
  • 483
  • 3
  • 11
3
votes
2 answers

Predis Protocol error: invalid bulk length

I am using predis and everything was great until I started getting this error: ERR Protocol error: invalid bulk length I am not sure why I am getting it. The error is in this file: Predis/Network/StreamConnection.php in this method: public function…
gprime
  • 2,283
  • 7
  • 38
  • 50
3
votes
1 answer

How to user predis for publish more than one time

How can I publish info between the clients more than once? I mean when I publish info from one user to other, he receives and backwards, but this is only once. Because when one user send something to the other, the GET is being loaded and the…
alebash
  • 195
  • 1
  • 2
  • 7
3
votes
0 answers

Laravel put :notify to the end of redis keys

recently I migrate from laravel 5.7 to 8 and some queues that dispatch from laravel has add to end of its key name ":notify"... somebody know why and how avoid this?.. i'm using predis as client.
zelti
  • 31
  • 1
1
2
3
16 17