mirror of https://github.com/dapr/docs.git
Merge branch 'master' into remove_nontransactional
This commit is contained in:
commit
bd909ec564
|
@ -69,13 +69,13 @@ KEYS "myApp*"
|
|||
If the data store supports SQL queries, you can query an actor's state using SQL queries. For example use:
|
||||
|
||||
```sql
|
||||
SELECT * FROM StateTable WHERE Id='<dapr-id>__delim__<actor-type>__delim__<actor-id>__delim__<key>'
|
||||
SELECT * FROM StateTable WHERE Id='<dapr-id>||<actor-type>||<actor-id>||<key>'
|
||||
```
|
||||
|
||||
You can also perform aggregate queries across actor instances, avoiding the common turn-based concurrency limitations of actor frameworks. For example, to calculate the average temperature of all thermometer actors, use:
|
||||
|
||||
```sql
|
||||
SELECT AVG(value) FROM StateTable WHERE Id LIKE '<dapr-id>__delim__<thermometer>__delim__*__delim__temperature'
|
||||
SELECT AVG(value) FROM StateTable WHERE Id LIKE '<dapr-id>||<thermometer>||*||temperature'
|
||||
```
|
||||
|
||||
> **NOTE:** Direct queries of the state store are not governed by Dapr concurrency control, since you are not calling through the Dapr runtime. What you see are snapshots of committed data which are acceptable for read-only queries across multiple actors, however writes should be done via the actor instances.
|
||||
|
|
|
@ -15,7 +15,7 @@ The easiest way to connect to your Cosmos DB instance is to use the Data Explore
|
|||
To get all state keys associated with application "myapp", use the query:
|
||||
|
||||
```sql
|
||||
SELECT * FROM states WHERE CONTAINS(states.id, 'myapp__delim__')
|
||||
SELECT * FROM states WHERE CONTAINS(states.id, 'myapp||')
|
||||
```
|
||||
|
||||
The above query returns all documents with id containing "myapp-", which is the prefix of the state keys.
|
||||
|
@ -25,25 +25,25 @@ The above query returns all documents with id containing "myapp-", which is the
|
|||
To get the state data by a key "balance" for the application "myapp", use the query:
|
||||
|
||||
```bash
|
||||
SELECT * FROM states WHERE states.id = 'myapp__delim__balance'
|
||||
SELECT * FROM states WHERE states.id = 'myapp||balance'
|
||||
```
|
||||
Then, read the **value** field of the returned document.
|
||||
|
||||
To get the state version/ETag, use the command:
|
||||
```bash
|
||||
SELECT states._etag FROM states WHERE states.id = 'myapp__delim__balance'
|
||||
SELECT states._etag FROM states WHERE states.id = 'myapp||balance'
|
||||
```
|
||||
## 4. Read actor state
|
||||
|
||||
To get all the state keys associated with an actor with the instance ID "leroy" of actor type "cat" belonging to the application with ID "mypets", use the command:
|
||||
|
||||
```bash
|
||||
SELECT * FROM states WHERE CONTAINS(states.id, 'mypets__delim__cat__delim__leroy__delim__')
|
||||
SELECT * FROM states WHERE CONTAINS(states.id, 'mypets||cat||leroy||')
|
||||
```
|
||||
And to get a specific actor state such as "food", use the command:
|
||||
|
||||
```bash
|
||||
SELECT * FROM states WHERE states.id = 'mypets__delim__cat__delim__leroy__delim__food'
|
||||
SELECT * FROM states WHERE states.id = 'mypets||cat||leroy||food'
|
||||
```
|
||||
|
||||
> **WARNING:** You should not manually update or delete states in the store. All writes and delete operations should be done via the Dapr runtime.
|
||||
|
|
|
@ -21,8 +21,8 @@ KEYS myapp*
|
|||
|
||||
The above command returns a list of existing keys, for example:
|
||||
```bash
|
||||
1) "myapp__delim__balance"
|
||||
2) "myapp__delim__amount"
|
||||
1) "myapp||balance"
|
||||
2) "myapp||amount"
|
||||
```
|
||||
|
||||
## 3. Get specific state data
|
||||
|
@ -32,24 +32,24 @@ Dapr saves state values as hash values. Each hash value contains a "data" field,
|
|||
For example, to get the state data by a key "balance" for the application "myapp", use the command:
|
||||
|
||||
```bash
|
||||
HGET myapp__delim__balance data
|
||||
HGET myapp||balance data
|
||||
```
|
||||
|
||||
To get the state version/ETag, use the command:
|
||||
```bash
|
||||
HGET myapp__delim__balance version
|
||||
HGET myapp||balance version
|
||||
```
|
||||
## 4. Read actor state
|
||||
|
||||
To get all the state keys associated with an actor with the instance ID "leroy" of actor type "cat" belonging to the application with ID "mypets", use the command:
|
||||
|
||||
```bash
|
||||
KEYS mypets__delim__cat__delim__leroy*
|
||||
KEYS mypets||cat||leroy*
|
||||
```
|
||||
And to get a specific actor state such as "food", use the command:
|
||||
|
||||
```bash
|
||||
HGET mypets__delim__cat__delim__leroy__delim__food value
|
||||
HGET mypets||cat||leroy||food value
|
||||
```
|
||||
|
||||
> **WARNING:** You should not manually update or delete states in the store. All writes and delete operations should be done via the Dapr runtime.
|
||||
|
|
|
@ -28,11 +28,11 @@ the ```spec/metadata``` section is an open key value pair metadata that allows a
|
|||
## Key scheme
|
||||
Dapr state stores are key/value stores. To ensure data compatibility, Dapr requires these data stores follow a fixed key scheme. For general states, the key format is:
|
||||
```bash
|
||||
<Dapr id>__delim__<state key>
|
||||
<Dapr id>||<state key>
|
||||
```
|
||||
For Actor states, the key format is:
|
||||
```bash
|
||||
<Dapr id>__delim__<Actor type>__delim__<Actor id>__delim__<state key>
|
||||
<Dapr id>||<Actor type>||<Actor id>||<state key>
|
||||
```
|
||||
|
||||
|
||||
|
@ -194,8 +194,8 @@ curl -X "DELETE" http://localhost:3500/v1.0/state/planet -H "ETag: xxxxxxx"
|
|||
|
||||
A Dapr-compatible state store shall use the following key scheme:
|
||||
|
||||
* *\<Dapr id>__delim__\<state key>* key format for general states
|
||||
* *\<Dapr id>__delim__\<Actor type>__delim__\<Actor id>__delim__\<state key>* key format for Actor states.
|
||||
* *\<Dapr id>||\<state key>* key format for general states
|
||||
* *\<Dapr id>||\<Actor type>||\<Actor id>||\<state key>* key format for Actor states.
|
||||
|
||||
### Concurrency
|
||||
Dapr uses Optimized Concurrency Control (OCC) with ETags. Dapr makes optional the following requirements on state stores:
|
||||
|
|
Loading…
Reference in New Issue