Skip to content

Commit aa37177

Browse files
authored
Update README.md
1 parent 9e7c93b commit aa37177

File tree

1 file changed

+65
-2
lines changed

1 file changed

+65
-2
lines changed

README.md

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,65 @@
1-
# Python-Redis-Server
2-
A miniature Radis Server made with python
1+
2+
# Python Redis Server
3+
4+
This is a simple implementation of a Redis clone written in Python.
5+
It is not meant to be a fully-featured Redis server, but rather a demonstration of how the Redis protocol works.
6+
7+
## Features
8+
9+
The following Redis commands are implemented:
10+
11+
- `PING`: Sends a `PONG` response to the client.
12+
- `ECHO`: Echoes back the provided argument to the client.
13+
- `SET`: Sets a key-value pair in the database. Optionally takes a `px` argument to set an expiry time in milliseconds.
14+
- `GET`: Gets the value of a key from the database. If the key has an expiry time set and it has passed, the key-value pair is deleted and `-1` is returned to the client.
15+
16+
## Running the Server
17+
18+
To run the server, simply execute the following command (it requires Python 3):
19+
20+
```
21+
./redis-clone
22+
```
23+
24+
The server will listen on `localhost:6379` for incoming connections.
25+
26+
## Connecting to the Server
27+
28+
You can use any Redis client to connect to the server. For example, to connect to the server using `redis-cli`, run the following command:
29+
30+
```
31+
redis-cli -h localhost -p 6379
32+
```
33+
34+
You should then see a `127.0.0.1:6379>` prompt, where you can enter Redis commands as you would with a regular Redis server.
35+
36+
## Limitations
37+
38+
This Redis clone has several limitations compared to a real Redis server:
39+
40+
- Only a limited set of commands are implemented.
41+
- The database is not persisted to disk, so all data is lost when the server is stopped.
42+
- There is no support for multiple databases or authentication.
43+
44+
## Common Bug
45+
46+
When running your server locally, you might see an error like this:
47+
48+
```
49+
Traceback (most recent call last):
50+
File "/.../python3.7/runpy.py", line 193, in _run_module_as_main
51+
"__main__", mod_spec)
52+
File "/.../python3.7/runpy.py", line 85, in _run_code
53+
exec(code, run_globals)
54+
File "/app/app/main.py", line 11, in <module>
55+
main()
56+
File "/app/app/main.py", line 6, in main
57+
s = socket.create_server(("localhost", 6379), reuse_port=True)
58+
AttributeError: module 'socket' has no attribute 'create_server'
59+
```
60+
61+
This is because `socket.create_server` was introduced in Python 3.8, and you
62+
might be running an older version.
63+
64+
You can fix this by installing Python 3.8 locally and using that.
65+

0 commit comments

Comments
 (0)