Question: 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.

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

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!