Key Value Stores
Key Value (KV) Stores provide a simple and efficient way to store and retrieve data at the edge. They can be used to store configuration data, user preferences, or any other data that needs to be quickly accessed by your edge functions.
Getting Started
To begin using KV Stores:
- Navigate to the “Compute > K/V Stores” section in the QuantCDN dashboard
- Click “Create New Store” to create a new KV store
- Give your store a name and description
- Once created, you’ll receive a unique identifier for your store
Managing Data
The QuantCDN dashboard provides a simple interface to:
- Add new key-value pairs
- Edit existing values
- View all stored data
- Search for specific keys
- Delete key-value pairs
Using KV Stores in Edge Functions
KV Stores can be easily integrated into your edge functions using the kvStore
object.
Storing Data
To store data in a KV store:
Retrieving Data
To retrieve data from a KV store:
Deleting Data
To delete data from a KV store:
JSON Data Handling
When storing JSON data in a KV store, the data is automatically encoded when stored and decoded when retrieved. This means you can directly store and retrieve JavaScript objects without manual JSON parsing.
Example Use Cases
KV Stores can be used for various purposes, such as:
- Storing user preferences or settings
- Caching API responses
- Managing feature flags
- Storing configuration data
- Maintaining rate limiting counters
- Storing temporary session data