Skip to content

jbn/grugstore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simplest Possible Content-Addressable Blob Store

This is a simple content-addressable blob store. It stores blobs of data and associated metadata. The blobs are stored in a directory hierarchy based on the base58 encoding of their SHA-256 hash. Metadata is stored as siblings to the blob file.

# Create a blob store (does nothing)
blobstore = GrugStore('some-dir', hierarchy_depth=3)

# Save a blob  ('some-dir/hash[0]/hash[1]/hash[2]/hash')
hash_str, file_path = blobstore.store(b'Hello, World!')

# Load a blob
blob = blobstore.load_bytes(hash_str)

# Save metadata
blobstore.store_sibling(hash_str, 'json', b'{"key": "value"}')

# Load metadata
metadata = blobstore.load_sibling_bytes(hash_str, 'json')

# Iter all items in the store
for hash_str, file_path in blobstore.iter_files(no_sibling=True):
    print(hash_str, file_path)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages