How-To: Share state between applications
Dapr offers developers different ways to share state between applications.
Different architectures might have different needs when it comes to sharing state. For example, in one scenario you may want to encapsulate all state within a given application and have Dapr manage the access for you. In a different scenario, you may need to have two applications working on the same state be able to get and save the same keys.
To enable state sharing, Dapr supports the following key prefixes strategies:
appid
- This is the default strategy. theappid
prefix allows state to be managed only by the app with the specifiedappid
. All state keys will be prefixed with theappid
, and are scoped for the application.
To specify a prefix strategy, add a metadata key named keyPrefix
on a state component:
The following examples will show you how state retrieval looks like with each of the supported prefix strategies:
A Dapr application with app id myApp
is saving state into a state store named redis
:
A Dapr application with app id myApp
is saving state into a state store named redis
:
The key will be saved as redis||darth
.
A Dapr application with app id myApp
is saving state into a state store named redis
:
The key will be saved as .