This example shows how to call redis through Layotto to add, delete, modify and query status data.
The architecture of this example is shown in the figure below, and the started processes are: redis, Layotto, client program
- Get the latest version of Redis docker image
Here we pull the latest version of the official image:
docker pull redis:latest- View the local mirror
Use the following command to check if redis is installed:
docker images- Run the container
After the installation is complete, we can use the following command to run the redis container:
docker run -itd --name redis-test -p 6380:6379 redisParameter Description:
-p 6380:6379: Map port 6379 of the container to port 6380 of the host. The outside can directly access the Redis service through the host ip:6380.
After downloading the project code to the local, enter the code directory and compile:
cd ${projectpath}/cmd/layotto
go buildThe layotto file will be generated in the directory, run it:
./layotto start -c ../../configs/config_state_redis.json cd ${projectpath}/demo/state/redis/
go build -o client
./clientIf the following information is printed, the call is successful:
SaveState succeeded.key:key1 , value: hello world
GetState succeeded.[key:key1 etag:1]: hello world
SaveBulkState succeeded.[key:key1 etag:2]: hello world
SaveBulkState succeeded.[key:key2 etag:2]: hello world
GetBulkState succeeded.key:key1,value:hello world
GetBulkState succeeded.key:key3,value:
GetBulkState succeeded.key:key2,value:hello world
GetBulkState succeeded.key:key5,value:
GetBulkState succeeded.key:key4,value:
DeleteState succeeded.key:key1
DeleteState succeeded.key:key2The client demo uses the golang version SDK provided by Layotto. The SDK is located in the sdk directory. Users can directly call the APIs provided by Layotto through the corresponding SDK.
Besides the SDK,you can also call Layotto server directly using grpc,which makes it easy for different language to interact with Layotto.

