|
1 |
| -# blockstore-core <!-- omit in toc --> |
2 |
| - |
3 | 1 | [](https://ipfs.tech)
|
4 | 2 | [](https://discuss.ipfs.tech)
|
5 | 3 | [](https://codecov.io/gh/ipfs/js-stores)
|
6 | 4 | [](https://github.com/ipfs/js-stores/actions/workflows/js-test-and-release.yml?query=branch%3Amain)
|
7 | 5 |
|
8 | 6 | > Contains various implementations of the API contract described in interface-blockstore
|
9 | 7 |
|
10 |
| -## Table of contents <!-- omit in toc --> |
11 |
| - |
12 |
| -- [Install](#install) |
13 |
| - - [Browser `<script>` tag](#browser-script-tag) |
14 |
| -- [Implementations](#implementations) |
15 |
| -- [Usage](#usage) |
16 |
| - - [BaseBlockstore](#baseblockstore) |
17 |
| - - [MemoryBlockstore](#memoryblockstore) |
18 |
| - - [BlackHoleBlockstore](#blackholeblockstore) |
19 |
| - - [TieredBlockstore](#tieredblockstore) |
20 |
| -- [API Docs](#api-docs) |
21 |
| -- [License](#license) |
22 |
| -- [Contribute](#contribute) |
23 |
| - |
24 |
| -## Install |
| 8 | +# Install |
25 | 9 |
|
26 | 10 | ```console
|
27 | 11 | $ npm i blockstore-core
|
28 | 12 | ```
|
29 | 13 |
|
30 |
| -### Browser `<script>` tag |
| 14 | +## Browser `<script>` tag |
31 | 15 |
|
32 | 16 | Loading this module through a script tag will make it's exports available as `BlockstoreCore` in the global namespace.
|
33 | 17 |
|
34 | 18 | ```html
|
35 | 19 | <script src="https://unpkg.com/blockstore-core/dist/index.min.js"></script>
|
36 | 20 | ```
|
37 | 21 |
|
38 |
| -## Implementations |
39 |
| - |
40 |
| -- Base: [`src/base`](src/base.ts) |
41 |
| -- Memory: [`src/memory`](src/memory.ts) |
42 |
| -- BlackHole: ['src/black-hole](src/black-hole.ts) |
43 |
| -- Tiered: ['src/tiered](src/tiered.ts) |
44 |
| - |
45 |
| -## Usage |
46 |
| - |
47 |
| -### BaseBlockstore |
48 |
| - |
49 |
| -Provides a complete implementation of the Blockstore interface. You must implement `.get`, `.put`, etc. |
50 |
| - |
51 |
| -```js |
52 |
| -import { BaseBlockstore } from 'blockstore-core/base' |
53 |
| - |
54 |
| -class MyCustomBlockstore extends BaseBlockstore { |
55 |
| - put (key, val, options) { |
56 |
| - // store a block |
57 |
| - } |
58 |
| - |
59 |
| - get (key, options) { |
60 |
| - // retrieve a block |
61 |
| - } |
62 |
| - |
63 |
| - // ...etc |
64 |
| -} |
65 |
| -``` |
66 |
| - |
67 |
| -### MemoryBlockstore |
68 |
| - |
69 |
| -A simple Blockstore that stores blocks in memory. |
70 |
| - |
71 |
| -```js |
72 |
| -import { MemoryBlockstore } from 'blockstore-core/memory' |
73 |
| - |
74 |
| -const store = new MemoryBlockstore() |
75 |
| -``` |
76 |
| - |
77 |
| -### BlackHoleBlockstore |
78 |
| - |
79 |
| -A Blockstore that does not store any blocks. |
80 |
| - |
81 |
| -```js |
82 |
| -import { BlackHoleBlockstore } from 'blockstore-core/black-hole' |
83 |
| - |
84 |
| -const store = new BlackHoleBlockstore() |
85 |
| -``` |
86 |
| - |
87 |
| -### TieredBlockstore |
88 |
| - |
89 |
| -A tiered blockstore wraps one or more blockstores and will query each in parallel to retrieve a block - the operation will succeed if any wrapped store has the block. |
90 |
| - |
91 |
| -Writes are invoked on all wrapped blockstores. |
92 |
| - |
93 |
| -```js |
94 |
| -import { TieredBlockstore } from 'blockstore-core/tiered' |
95 |
| - |
96 |
| -const store = new TieredBlockstore([ |
97 |
| - store1, |
98 |
| - store2, |
99 |
| - // ...etc |
100 |
| -]) |
101 |
| -``` |
102 |
| - |
103 |
| -## API Docs |
| 22 | +# API Docs |
104 | 23 |
|
105 | 24 | - <https://ipfs.github.io/js-stores/modules/blockstore_core.html>
|
106 | 25 |
|
107 |
| -## License |
| 26 | +# License |
108 | 27 |
|
109 | 28 | Licensed under either of
|
110 | 29 |
|
111 | 30 | - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
112 | 31 | - MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
113 | 32 |
|
114 |
| -## Contribute |
| 33 | +# Contribute |
115 | 34 |
|
116 | 35 | Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-stores/issues).
|
117 | 36 |
|
|
0 commit comments