Experimental standalone state storage service for crawlers at www.microprediction.org
Project description
microstate
Simple REST state storage tied to a write key
Creating a state writer
from microstate import MicroStateWriter
from microprediction import new_key
write_key = new_key(difficulty=11) # Takes a while!
msw = 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:
msw.set(value=data)
Retrieve data:
data = msw.get()
Usage pattern 2 (using a logical memory location from 0 to 99)
Store data with a location index
msw.set(value=data, k=34)
Retrieve data with a location index
data = msw.get(k=34)
Other data types
In addition to dict, or list, data may be str, int or float. However it will be stored internally as a binary string. Be aware of this when retrieving the data.
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
microstate-0.0.6.tar.gz
(5.0 kB
view hashes)
Built Distribution
Close
Hashes for microstate-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f621e335f4bd9914eaea97a40952f29f180923a0876977e3c10062b6c3c876c |
|
MD5 | 7c7628fea964cf8c14e3d184376f78d8 |
|
BLAKE2b-256 | 01738748b931c8593bb59a71fa55749a280be0693e8720f2246fd09eee950738 |