Skip to content

Commit

Permalink
Merge pull request #9 from roansong/patch-2
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
Attumm authored Jul 20, 2021
2 parents e8e6dd7 + 972c0c6 commit c69fc82
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Redis Dict
# redis-dict
[![Build Status](https://travis-ci.com/Attumm/redis-dict.svg?branch=main)](https://travis-ci.com/Attumm/redis-dict)

Dictionary with Redis as storage back-end.
A Python dictionary with Redis as the storage back-end.
Redis is a great database for all kinds of environments; from simple to complex.
redis-dict tries to make using Redis as simple as using a dictionary.
redis-dict stores data in Redis with key values, this is according to Redis best practices.
This also allows other non-python programs to access the data stored in Redis.
redis-dict stores data in Redis with key-values, this is according to [Redis best practices](https://redislabs.com/redis-best-practices/data-storage-patterns/).
This also allows other non-Python programs to access the data stored in Redis.

redis-dict was build out of the necessity of working with incredible large data sets.
It had to be possible to only send or receive data the required data over the wire and into memory.
And with redis-dict it's as simple as a dictionary.
redis-dict was built out of the necessity of working with incredibly large data sets.
It had to be possible to only send or receive the required data over the wire and into memory.
With redis-dict it's as simple as a dictionary.

## Example
Redis is a really fast database if used right.
redis-dict uses Redis as key value storage.
redis-dict uses Redis for key-value storage.
```python
>>> from redis_dict import RedisDict
>>> dic = RedisDict(namespace='bar')
Expand All @@ -39,15 +39,15 @@ In Redis our example looks like this.
## Features

#### Dictionary
redis-dict can be used in drop in replacement of a normal dictionary as long no referenced datascructed are used.
i.e no nested layout
e.g values such list, instance and other dictionaries.
When used with supported types in can be used a drop in for a normal dictionary.
redis-dict can be used as a drop-in replacement for a normal dictionary as long as no datastructures are used by reference.
i.e. no nested layout
e.g. values such list, instance and other dictionaries.
When used with supported types, it can be used a drop-in for a normal dictionary.

redis-dict has all the methods and behavior of a normal dictionary.

#### Types
Several python types can be saved and retrieved as the same type.
Several Python types can be saved and retrieved as the same type.
As of writing, redis-dict supports the following types.
* String
* Integer
Expand All @@ -56,21 +56,21 @@ As of writing, redis-dict supports the following types.
* None

#### Expire
Redis has the great feature of expiring keys, this feature is supported.
1. you can set default expiration when creating redis-dict instance.
Redis has the great feature of expiring keys. This feature is supported.
1. You can set the default expiration when creating a redis-dict instance.
```python
r_dic = RedisDict(namespace='app_name', expire=10)
```
2. With context manager you can temporary set the default expiration time you have set.
Defaults to None (do not expire)
2. With a context manager you can temporarily set the default expiration time.
Defaults to None (does not expire)
```python
seconds = 60
with r_dic.expire_at(seconds):
r_dic['gone_in_sixty_seconds'] = 'foo'
```

#### Batching
Batch your requests by using Pipeline, as easy as using context manager
Batch your requests by using Pipeline, as easy as using a context manager

Example storing the first ten items of Fibonacci, with one round trip to Redis.
```python
Expand All @@ -85,13 +85,13 @@ with r_dic.pipeline():
r_dic[str(index)] = item
```

#### Namescape
Redis-dict uses name spaces by default. This allows you to have an instance of Redis-dict per project.
#### Namespaces
redis-dict uses namespaces by default. This allows you to have an instance of redis-dict per project.
When looking directly at the data in Redis, this gives you the advantage of directly seeing which data belongs to which app.
This also has the advantage that it is less likely for apps to collide with keys, which is a difficult problem to debug.

### More Examples
More complex examples of Redis-dict can be found in the tests. All functionality is tested in either[ `assert_test.py` (here)](https://github.com/Attumm/redis-dict/blob/master/assert_test.py#L1) or in the [unit tests (here)](https://github.com/Attumm/redis-dict/blob/master/tests.py#L1).
More complex examples of redis-dict can be found in the tests. All functionality is tested in either[ `assert_test.py` (here)](https://github.com/Attumm/redis-dict/blob/master/assert_test.py#L1) or in the [unit tests (here)](https://github.com/Attumm/redis-dict/blob/master/tests.py#L1).

## Installation
```sh
Expand Down

0 comments on commit c69fc82

Please sign in to comment.