Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can anyone help me with this assignment? Please write in Python. Thank You! Redis is a popular in-memory data structure store that is widely used

Can anyone help me with this assignment? Please write in Python. Thank You!

Redis is a popular in-memory data structure store that is widely used in many applications, either as cache, complex data structure, or store application data itself.

In this assignment, your task is to build a simple, stripped-down version of Redis named Ledis. Your Ledis app can run entirely on a single web page, meaning you do not need a web server. Do not use other database systems (PostgreSQL, MySQL, Redis, etc).

You need to implement these functionalities:

  • Data structures: String, Set

  • Special features: Expire, snapshots

  • A simple web CLI (similar to redis-cli)

Commands

Your Ledis should be able to handle the following. Note that these are modeled after Redis commands, so feel free to refer to Redis manual when you have questions.

String:

  • SET key value: set a string value, always overwriting what is saved under key

  • GET key: get a string value at key

Set: Set is a unordered collection of unique string values (duplicates not allowed)

  • SADD key value1 [value2...]: add values to set stored at key

  • SREM key value1 [value2...]: remove values from set

  • SMEMBERS key: return array of all members of set

  • SINTER [key1] [key2] [key3] ...: (bonus) set intersection among all set stored in specified keys. Return array of members of the result set

Data Expiration:

  • KEYS: List all available keys

  • DEL key: delete a key

  • EXPIRE key seconds: set a timeout on a key, seconds is a positive integer (by default a key has no expiration). Return the number of seconds if the timeout is set

  • TTL key: query the timeout of a key

Snapshot (bonus):

  • SAVE: save current state in a snapshot

  • RESTORE: restore from the last snapshot

Error Handling: When an error happens, simply return ERROR, together with the cause of error if possible. Example: ERROR: Key not found

Web CLI

Please build a simple web-based CLI interface which allows user to enter commands and displays the result.

image text in transcribed

>SET hello world OK >GET hello "world" >Ledis: KEYS

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions

Question

Calculate the lifetime value (LTV) of a loyal customer.

Answered: 1 week ago