Basics of Redis

Basics

Redis is:

  • NoSQL
  • KeyValue
  • In memory
  • Data Structure Server
    • binary safe strings
    • lists, sets, sorted sets, hashes
    • bitmaps, hyperloglogs
  • Open source

Redis is:

  • Fast
  • Low CPU Requirement
  • Scalable

Redis can be used as:

  • Cache
  • Analytics
  • Leaderboard
  • Queues
  • Cookie storage
  • Expiring data
  • Messaging
  • High I/O workloads
  • API throttlings

How to persist your data

  • Snapshot
  • AOF: Append Only File

Pros:

  • Redis has both data store and job queue built in
  • Redis is a data structure server so is has flexibe data structures
  • Redis is fast

Cons:

  • Redis used a lot of RAM
  • Redis can be be queued by value

Comparisons

  • SQL
  • NoSQL
  • Flat file
  • Rabbit
  • ActiveMQ

How to Use it

Redis can be used as a handy data storage for data science projects. It can also be used as an API. Redis can be used on a medium data file. It can be used as a way to store medium size data file and also read out for analysis.

Installation

Test

Invoke the command line

redis-cli

Useful commands

  • set: set test "just a test"
  • get: get test

Python

redis on pypi

import redis

r \= redis.Redis(host\='localhost', port\=6379, db\=0)

print("setting keys")
r.set('test', 'just a test in python')

print('getting values')
print(

r.get('test')

)

FastAPI

The youtube channel Full Stack Book made a short video on how to integrate redis into FastAPI1.

Planted: by ;

wiki/computation/basics-of-redis Links to:

LM (2021). 'Basics of Redis', Datumorphism, 01 April. Available at: https://datumorphism.leima.is/wiki/computation/basics-of-redis/.