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.
The Redis resource creates a persistent virtual filesystem backed by
Redis. It supports full read and write operations.
Config
from mirage import MountMode, Workspace
from mirage.resource.redis import RedisResource
resource = RedisResource(
url="redis://localhost:6379/0",
key_prefix="mirage:fs:",
)
ws = Workspace({"/redis": resource}, mode=MountMode.WRITE)
| Parameter | Required | Default | Description |
|---|
url | no | redis://localhost:6379/0 | Redis connection URL |
key_prefix | no | mirage:fs: | Key namespace prefix |
Keys are stored as:
{prefix}file:{path} - file content (raw bytes)
{prefix}dir - Redis set of directory paths
{prefix}modified:{path} - modification timestamps
Filesystem Layout
/redis/
<file>
<directory>/
<file>
<subdirectory>/
<file>
The filesystem is fully user-defined - create any directory structure
with mkdir, touch, tee, etc.
Example:
/redis/
config.json
logs/
app.log
error.log
cache/
session-abc.json
Cache
Index TTL is 0 - always reads fresh state from Redis.
Example
import asyncio
from mirage import MountMode, Workspace
from mirage.resource.redis import RedisResource
resource = RedisResource(url="redis://localhost:6379/0")
async def main():
ws = Workspace({"/redis": resource}, mode=MountMode.WRITE)
# Create directories and files
await ws.execute("mkdir -p /redis/data/")
await ws.execute('echo "hello world" | tee /redis/data/hello.txt')
# Read back
r = await ws.execute("cat /redis/data/hello.txt")
print(await r.stdout_str())
# List files
r = await ws.execute("ls /redis/data/")
print(await r.stdout_str())
# Copy and move
await ws.execute("cp /redis/data/hello.txt /redis/data/copy.txt")
await ws.execute("mv /redis/data/copy.txt /redis/data/renamed.txt")
# Search
r = await ws.execute('grep "hello" /redis/data/')
print(await r.stdout_str())
# Clean up
await ws.execute("rm -r /redis/data/")
if __name__ == "__main__":
asyncio.run(main())
Shell Commands
| Command | Notes |
|---|
ls | List files and directories |
cat | Read file content |
head / tail | First/last N lines |
grep / rg | Pattern search |
wc | Line/word/byte counts |
find | Recursive search with -name, -maxdepth |
tree | Directory tree view |
mkdir | Create directories |
touch | Create empty files |
cp / mv / rm | Copy, move, delete |
tee | Write stdin to file |
diff / cmp | Compare files |
sort / cut / tr | Text processing |
tar / zip / gzip | Compression |
base64 / md5 / sha256sum | Encoding and checksums |