diff --git a/README.md b/README.md index 6d2a318..9eae6cd 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,12 @@ redistructures ? Dictionary, List, Set, Queue, Counter implemented in python with redis data store under the hood ### Examples +All examples in `example/structures.py` + +Dictionary example : ```python from redistructures import Struct -d = Struct.dictionary() +d = Struct.dictionary('hey') d['x'] = 'y' d['w'] = 'v' print(d['x']) @@ -20,3 +23,26 @@ for v in d.values(): for k, v in d.items(): print(k, v) ``` +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' +``` diff --git a/example/structures.py b/example/structures.py index 28d29c0..d30f417 100644 --- a/example/structures.py +++ b/example/structures.py @@ -69,9 +69,15 @@ def test_list(): print(e) print('-'*50) +def test_dict2(): + d = Struct.dictionary() + for k, v in d.items(): + print(k, v) + if __name__ == '__main__': test_dict() test_set() test_counter() test_queue() test_list() + test_dict2()