You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -5,187 +5,71 @@ description: Learn how to use CommandKit's built-in key-value store for persiste
5
5
6
6
# Key-Value Store
7
7
8
-
CommandKit provides a built-in key-value store implementation using SQLite for persistent data storage. This guide will show you how to use the KV store effectively in your bot for storing configuration, user data, and other persistent information.
8
+
The CommandKit Key-Value (KV) store provides a simple, persistent storage solution using SQLite. It supports storing any JSON-serializable data types directly, including objects, arrays, dates, maps, sets, and more.
9
9
10
-
## What is the KV Store?
10
+
## Features
11
11
12
-
The KV store is a simple, persistent key-value storage solution that:
13
-
14
-
-**Persistent**: Data is stored in a SQLite database file
15
-
-**Namespaced**: Organize data into logical groups using namespaces
16
-
-**Type-safe**: Full TypeScript support with proper typing
17
-
-**Iterable**: Use standard JavaScript iteration patterns
18
-
-**Resource-safe**: Implements disposable patterns for automatic cleanup
19
-
20
-
## When to Use the KV Store
21
-
22
-
Use the KV store when you need to:
23
-
24
-
- Store user preferences and settings
25
-
- Cache frequently accessed data persistently
26
-
- Store bot configuration that needs to survive restarts
27
-
- Keep track of user statistics and progress
28
-
- Store temporary data that needs to persist between sessions
29
-
30
-
:::warning Node.js Version Requirement
31
-
The KV store requires Node.js version that supports the `node:sqlite` module. Make sure you're using a compatible Node.js version.
32
-
:::
33
-
34
-
## Basic Setup
35
-
36
-
The KV store is available directly from the CommandKit package:
37
-
38
-
```ts
39
-
import { KV, openKV } from'commandkit/kv';
40
-
```
12
+
-**JSON Serialization**: Store any JSON-serializable data types directly
13
+
-**Dot Notation**: Access nested properties using dot notation (e.g., `user:123.settings.theme`)
14
+
-**Namespaces**: Organize data into separate namespaces
15
+
-**Expiration**: Set time-to-live (TTL) for automatic cleanup
0 commit comments