EdgeOne Pages KV is a multi-edge node deployed KV persistent data storage that allows users to read and write data globally. It follows final consistency and ensures global sync access within 60s. You can combine the function capability in EdgeOne Pages to build APIs or websites that require storing small amounts of data.
Case
Counter
Based on your business needs, you can store the number of clicks for a certain button or page in EdgeOne Pages KV. When clicked, refresh the key-value record in KV so that you can perform statistics and analysis on click or access behavior.
Keystore
For sensitive info that should not be placed in a code repository, you can store it in Edgeone Pages KV and dynamically obtain it for better protection of your data.
Shopping Cart
Edgeone Pages KV retains user data across multiple Pages and terminals, helping you conveniently implement simple business requirements like user shopping carts and user orders.
Basic Concept
Account
The Edgeone Pages KV Account is the minimum unit for KV Usage Statistics and billing in Pages Business. An EdgeOne Pages account corresponds to a KV Account, created after user activation on the console page. Account storage capacity: 100MB.
Namespace
A namespace is the basic unit of data isolation in Edgeone Pages KV. Each namespace can be considered an independent database, with data between namespaces not interfering with one another. An account can create 10 namespaces.
Key-Value Pair
A Key-Value pair is a structure for storing data, where each data item consists of two parts: a Key and a Value. The Key is a unique identifier for user identification, and the Value is the associated data linked to the Key.
Variable Name
The variable name is the runtime environment variable name defined when binding a project to a namespace. Before using namespace data, you must first bind the namespace to the Edgeone Pages Project. The binding relationship between namespaces and projects is many-to-many, and different runtime environment variable names are used to distinguish them during binding.
Quick Start
Initializing Account
1. Enter Console: Switch to the "KV Storage" page.
2. Open an Account: Click the "Apply Now" button.
Note:
Note: Currently, KV storage has a limited quota. Please apply for enabling. We will process as soon as possible. Once the application is successful, it can be used.
Creating a Namespace
1. Enter Namespace List: After enabling the KV Account, click the "Create Namespace" button on the "KV Storage" page.
2. Create a namespace: Manually input the namespace name you need to create, click the "Create" button, and wait for the creation to complete.
3. Creation completed: After creation, you can view the namespace created on the namespace list page.
Adding a Record
1. Enter namespace details: In the namespace list, click the corresponding namespace name to enter namespace details.
2. Add Record: Click the "Create Record" button.
3. Creation completed: After creation, you can view the added records in the list.
Binding a Namespace
Namespace and project binding can be performed in both "Project" and "KV Storage".
Bind in KV Storage
1. Enter Associated Project: In the namespace details page, click the "Bind Project" tab.
2. Bind Project: Click the "Bind Project" button.
3. Binding succeeded: After successful binding, you can view the bound project in the bind project list.
Binding in the Project
1. Enter Project - KV Storage: After entering the project detail, click the "KV Storage" menu.
2. Bind a namespace: Click the "Bind Namespace" button.
3. Binding succeeded: After binding succeeds, you can view the bound namespace in the Bind Namespace List.
Using KV
Note: The my_kv in the following example is the variable name when you bind the project to the namespace, as set in the figure above.
Currently provides a group of KV storage operation methods for Edgeone Pages function usage. Follow these steps:
put
Write KV data, the user creates a new key-value pair or updates the value of an existing key-value pair.
Counter Template: It lets users record and display the occurrence count of project business needs, and can be used to track "clicks", "blog access traffic" and other business scenarios.