First be sure you have redis php extension installed by running: php -m
in your terminal and you will see the list of installed modules. Redis should be on the list. If it is not, please install it to your PHP version, or install new version of PHP which contains redis by default as described here:
To install and run redis, follow these steps
- go to https://redis.io/download and download latest stable version
- open terminal, go to your downloaded redis folder and run
make
- while still in your redis installed folder, run redis with terminal command
src/redis-server
- open new terminal window and go to same redis installed folder and type
src/redis-cli
to start interacting with your redis instance
Let's make a small test, let's create first key value pair in our redis cache. Open your terminal, go to redis installed folder and type src/redis-cli
to start the instance and then type
set 'testKey' 'testvalue'
now when the key is created, we can check does it exist by using this command:
keys '*'
as a response you should see this:
127.0.0.1:6379> keys '*'
1) "testKey"
And that is it, your redis is ready to be used, for more info visit official redis page: