Skip to content

Commit d505f03

Browse files
committed
update store docs
1 parent fabb884 commit d505f03

1 file changed

Lines changed: 32 additions & 4 deletions

File tree

docs/user-guide/storage.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@ print(group)
3535
```
3636

3737
```python exec="true" session="storage" source="above" result="ansi"
38-
# Implicitly creates a MemoryStore
38+
# Implicitly creates a MemoryStore backed by a regular `dict`
3939
data = {}
4040
group = zarr.create_group(store=data)
4141
print(group)
4242
```
4343

44+
```python exec="true" session="storage" source="above" result="ansi"
45+
# Creates a ManagedMemoryStore backed by a `dict` managed by Zarr
46+
group = zarr.create_group(store="memory://my-store")
47+
print(group)
48+
```
49+
4450
[](){#user-guide-store-like}
4551
### StoreLike
4652

@@ -83,6 +89,12 @@ print(group)
8389
create a [memory store](#memory-store), using this dictionary as the
8490
[`store_dict` argument][zarr.storage.MemoryStore].
8591

92+
- a `memory://` URL string, which will create a [managed memory store](#managed-memory-store):
93+
```python exec="true" session="storage" source="above" result="ansi"
94+
group = zarr.create_group(store="memory://my-store/path")
95+
print(group)
96+
```
97+
8698
- an FSSpec [FSMap object](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.FSMap),
8799
which will create an [FsspecStore](#remote-store).
88100

@@ -91,9 +103,9 @@ print(group)
91103

92104
## Explicit Store Creation
93105

94-
In some cases, it may be helpful to create a store instance directly. Zarr-Python offers four
95-
built-in store: [`zarr.storage.LocalStore`][], [`zarr.storage.FsspecStore`][],
96-
[`zarr.storage.ZipStore`][], [`zarr.storage.MemoryStore`][], and [`zarr.storage.ObjectStore`][].
106+
In some cases, it may be helpful to create a store instance directly. Zarr-Python offers six
107+
built-in stores: [`zarr.storage.LocalStore`][], [`zarr.storage.FsspecStore`][],
108+
[`zarr.storage.ZipStore`][], [`zarr.storage.MemoryStore`][], [`zarr.storage.ManagedMemoryStore`][], and [`zarr.storage.ObjectStore`][].
97109

98110
### Local Store
99111

@@ -164,6 +176,22 @@ array = zarr.create_array(store=store, shape=(2,), dtype='float64')
164176
print(array)
165177
```
166178

179+
### Managed Memory Store
180+
181+
The [`zarr.storage.ManagedMemoryStore`][] is an in-memory store like `MemoryStore`, except
182+
`ManagedMemoryStore` manages the dictionary internally. This allows Zarr to create a `ManagedMemoryStore`
183+
from a string URL. Using the same store name will return a store backed by the same underlying dictionary.
184+
185+
```python exec="true" session="storage" source="above" result="ansi"
186+
store = zarr.storage.ManagedMemoryStore(name="data")
187+
url = str(store)
188+
# "memory://data/"
189+
array_1 = zarr.create_array(store=store, name='a1', shape=(2,), dtype='float64')
190+
array_2 = zarr.create_array(url, name='a2', shape=(2,), dtype='uint8')
191+
print(array_1)
192+
print(array_2)
193+
```
194+
167195
### Object Store
168196

169197
[`zarr.storage.ObjectStore`][] stores the contents of the Zarr hierarchy using any ObjectStore

0 commit comments

Comments
 (0)