- You need to install a distros(distribution) for Linux lets take Ubuntu
- First you need wsl (Also disable your antivirus, because sometimes it cries. This is 100% safe)
- Open cmd or powershell as admin
wsl --install
- List out all distros
wsl --list --online
- Install Ubuntu
wsl --install -d Ubuntu
- Open Ubuntu from search bar
- For the first time it will ask you to set name and password
- Then install package universe
sudo add-apt-repository universe
, this will allow you to install all the open-source package like Redis which do not come under Ubuntu - Finally install Redis
sudo apt-get intall redis
- Open cmd or powershell as admin
- Congratulations 🎉 You have installed Redis, now to start Redis Server on you local machine type
redis-server
in your Ubuntu terminal. - Now open another Ubuntu terminal and type
redis-cli
, now you can communicate with your redis server - Remember not to close your Redis Server
Note - < abc > needs to be replaced by appropriate data KV - Key-Value
SET <KEY_NAME> <VALUE>
🔸Set a key-value in redis volitile storageGET <KEY_NAME>
🔸Get the value for given KEY_NAMEKEYS *
🔸 Get all keysEXISTS <KEY_NAME>
🔸Check if a key existsFLUSHALL
🔸Removes all saved up key-value pairsCLEAR
🔸Clear's the consoleEXPIRE <KEY_NAME> <SECONDS>
🔸For existing key set expiration timeSETEX <KEY_NAME> <SECONDS> <VALUE>
🔸Set a new key with expiration time
LPUSH <KEY_NAME> <VALUE>
🔸Add's KV at the startRPUSH <KEY_NAME> <VALUE>
🔸Add's KV at the endLPOP <KEY_NAME>
🔸Remove's KV from startRPOP <KEY_NAME>
🔸Remove's KV from endLRANGE <KEY_NAME> <START> <END>
🔸 Log's all the KV's from range start to end
SADD <KEY_NAME> <VALUE>
🔸Add KV in setSMEMBERS <KEY_NAME>
🔸Log's all the KV pair's in setSREM <KEY_NAME> <VALUE>
🔸Remove's KV from set
Hash in Redis gives user's a way to store multiple field's and value's for a key. Additionally it allow user to store complex data.
HSET <KEY> <FIELD> <VALUE>
🔸 Add's key-{field, value} in hashHGET <KEY> <FIELD>
🔸Get the value for a key's fieldHGETALL <KEY>
🔸Get all Field and Values for a KeyHDEL <KEY> <FIELD>
🔸Removes Field and Value for a given fieldHEXISTS <KEY> <FIELD>
🔸Check if a field exists