2020-08-17 12:16:49 +02:00
|
|
|
redistructures ?
|
|
|
|
====
|
|
|
|
|
|
|
|
### Description
|
2020-08-17 17:19:15 +02:00
|
|
|
Dictionary, List, Set, Queue, Counter implemented in python with redis data store under the hood
|
2020-08-17 12:16:49 +02:00
|
|
|
|
|
|
|
### Examples
|
2020-08-17 17:26:08 +02:00
|
|
|
All examples in `example/structures.py`
|
|
|
|
|
|
|
|
Dictionary example :
|
2020-08-17 12:16:49 +02:00
|
|
|
```python
|
|
|
|
from redistructures import Struct
|
2020-08-17 17:26:08 +02:00
|
|
|
d = Struct.dictionary('hey')
|
2020-08-17 12:16:49 +02:00
|
|
|
d['x'] = 'y'
|
|
|
|
d['w'] = 'v'
|
|
|
|
print(d['x'])
|
|
|
|
print('x' in d)
|
|
|
|
print('q' in d)
|
|
|
|
for k in d.keys():
|
|
|
|
print(k)
|
|
|
|
for v in d.values():
|
|
|
|
print(v)
|
|
|
|
for k, v in d.items():
|
|
|
|
print(k, v)
|
|
|
|
```
|
2020-08-17 17:26:08 +02:00
|
|
|
output
|
|
|
|
```
|
|
|
|
b'y'
|
|
|
|
True
|
|
|
|
False
|
|
|
|
b'dict:x'
|
|
|
|
b'dict:w'
|
|
|
|
b'y'
|
|
|
|
b'v'
|
|
|
|
b'dict:x' b'y'
|
|
|
|
b'dict:w' b'v'
|
|
|
|
```
|
|
|
|
After next run
|
|
|
|
```
|
|
|
|
d = Struct.dictionary('hey')
|
|
|
|
for k, v in d.items():
|
|
|
|
print(k, v)
|
|
|
|
```
|
|
|
|
output
|
|
|
|
```
|
|
|
|
b'dict:x' b'y'
|
|
|
|
b'dict:w' b'v'
|
|
|
|
```
|