> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Namespace

> Where a workspace keeps symlinks and file attributes, in memory, on disk or on Redis.

The namespace store keeps what a backend has no place for:

* Symlinks made with `ln -s`.
* Modes, owners and times that `chmod`, `chown` and `touch` set on a backend
  that cannot store them.
* Extended attributes set with `setfattr`.

Every instance of the workspace on the same store sees the same links and
attributes.

| `type` | Keeps them | Keys |
| - | - | - |
| `ram` | In the process's memory, until it exits | |
| `disk` | In files under `root` | `root`, default `~/.mirage/state` |
| `redis` | On Redis, under `key_prefix` and the workspace id | `url`, `key_prefix`, default `mirage:` |

`store.namespace` moves only this store. `store.type` moves it together with
the others, as the [overview](https://docs.mirage.strukto.ai/home/infrastructure/overview.md#one-store-or-several)
shows.

Set `store.type` as well. A `store` block without it keeps the other
stores in memory, even on a server: the server keeps them on disk only
when the config has no `store` block. The examples below set
`type: disk`, which matches that default.

## On disk

> [tab] YAML
>
> ```yaml theme={null}
> workspace_id: agent
> store:
>   type: disk
>   namespace:
>     type: disk
>     root: /var/lib/mirage
> ```

> [tab] Python
>
> ```python theme={null}
> from mirage import Workspace
> from mirage.workspace.store import DiskWorkspaceStateStore
>
> store = DiskWorkspaceStateStore(
>     namespace=DiskWorkspaceStateStore(root="/var/lib/mirage"),
> )
> ws = Workspace(mounts, workspace_id="agent", store=store, owns_store=True)
> ```

> [tab] TypeScript
>
> ```typescript theme={null}
> import { DiskWorkspaceStateStore, Workspace } from '@struktoai/mirage-node'
>
> const store = new DiskWorkspaceStateStore({
>   namespace: new DiskWorkspaceStateStore({ root: '/var/lib/mirage' }),
> })
> const ws = new Workspace(mounts, { workspaceId: 'agent', store, ownsStore: true })
> ```

## On Redis

> [tab] YAML
>
> ```yaml theme={null}
> workspace_id: agent
> store:
>   type: disk
>   namespace:
>     type: redis
>     url: redis://redis.internal:6379/0
> ```

> [tab] Python
>
> ```python theme={null}
> from mirage import Workspace
> from mirage.workspace.store import DiskWorkspaceStateStore, RedisWorkspaceStateStore
>
> store = DiskWorkspaceStateStore(
>     namespace=RedisWorkspaceStateStore(url="redis://redis.internal:6379/0"),
> )
> ws = Workspace(mounts, workspace_id="agent", store=store, owns_store=True)
> ```

> [tab] TypeScript
>
> ```typescript theme={null}
> import { DiskWorkspaceStateStore, RedisWorkspaceStateStore, Workspace } from '@struktoai/mirage-node'
>
> const store = new DiskWorkspaceStateStore({
>   namespace: new RedisWorkspaceStateStore({ url: 'redis://redis.internal:6379/0' }),
> })
> const ws = new Workspace(mounts, { workspaceId: 'agent', store, ownsStore: true })
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.