Metadata-Version: 2.1
Name: microstate
Version: 0.2.0
Summary: Experimental standalone state storage service for crawlers at www.microprediction.org
Home-page: https://github.com/microprediction/microstate
Author: microprediction
Author-email: info@microprediction.org
License: MIT
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Description-Content-Type: text/markdown
Requires-Dist: microconventions (>=0.1.0)
Requires-Dist: redis
Requires-Dist: fakeredis
Requires-Dist: numpy
Requires-Dist: pathlib
Requires-Dist: requests
Requires-Dist: getjson

# microstate 

Simple REST state storage tied to a write key

### You need a key 

    from microstate import MicroStateWriter
    write_key = MicroStateWriter.create_key(difficulty=11) # Takes a while! 

to instantiate a writer

    writer = MicroStateWriter(write_key=write_key)

### Usage pattern 1

Assume we have data taking the form of a dictionary

    data = {'age':17,'model':'my model','params':{'mean':17,'std':10}

Store data: 

    writer.set(value=data)

Retrieve data:

    data = writer.get()     

### Usage pattern 2 (using a logical memory location from 0 to 99)

Store data with a location index

    writer.set(value=data, k=34)

Retrieve data with a location index

    data = writer.get(k=34) 

### Other data types (caution!)

- Tuples will be converted to lists
- int, float to string

To preserve types use dict or list 

### Partial support for tuple

Tuples can be stored but will be converted to list. 

### Memory limits 

Assuming a write key of difficulty at least 11:

    location  0      holds    320 kb
    locations 1-319  hold       1 kb each 



