Skip to content

Commit

Permalink
improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Tevinthuku committed Apr 15, 2024
1 parent ca48ac0 commit a3febb4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions memcached/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
## Running the server

`cargo run`
```bash
cargo run
```

In a new terminal, connect to the server via telnet:
you can also set the cache size. ie: The max number of bytes the server can hold. The default is `1000 bytes` if the `CACHE_SIZE` flag is not provided.

```bash
CACHE_SIZE=2000 cargo run
```

In a new terminal, connect to the server via telnet:

```bash
telnet localhost 11211
```

Passing some commands:

set a value

```
```bash
set test 0 0 4
1234
```

get a value

```
```bash
get test
```
2 changes: 1 addition & 1 deletion memcached/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct DbState {
entries: MapWithByteSizeCount,
}

// We want to keep track of the byte size of the content so that we can remove the oldest content if the cache size exceeds the max_cache_size_in_bytes
// We want to keep track of the byte size of the content so that we can remove the oldest content if the entire content byte count exceeds the max_cache_size_in_bytes
// The LinkedHashMap maintains insertion order, so we can remove the oldest content first
// the byte_count field provides a single lookup to get the total byte size of the content stored in the map
#[derive(Default)]
Expand Down

0 comments on commit a3febb4

Please sign in to comment.