Java built-in serialization/deserialization mechanism is not only verbose but also platform dependent, which makes it not a good choice for RPC.
This project will work as a showcase for spring redis caching in json and protobuf format.
The project requires at least JDK 7, protobuf, redis and Maven 3.0.
mvn clean jetty:run
-
Save data to redis
http://localhost:8080/users/to-redis/3
Server response body
{"id":3,"userName":"中文测试-UserName","userGroup":{"id":3,"userGroupName":"中文测试-GroupName"}}
-
Fetch data from redis
http://localhost:8080/users/from-redis/3
Server response body
{"id":3,"userName":"中文测试-UserName","userGroup":{"id":3,"userGroupName":"中文测试-GroupName"}}
-
Save data to redis
http://localhost:8080/users/to-redis-protobuf/4
Server response body
{"id":4,"userName":"中文测试-UserName-protobuf","userGroup":{"id":4,"userGroupName":"中文测试-GroupName-protobuf"}}
-
Fetch data to redis(default Content-Type: application/xml)
http://localhost:8080/users/from-redis-protobuf/4
Server response body
<User> <id>4</id> <userName>\344\270\255\346\226\207\346\265\213\350\257\225-UserName-protobuf</userName> <userGroup> <id>4</id> <userGroupName>\344\270\255\346\226\207\346\265\213\350\257\225-GroupName-protobuf</userGroupName> </userGroup> </User>
-
Fetch data from redis as json
curl -H "Accept: application/json" http://localhost:8080/users/from-redis-protobuf/4
Server response body
{"id": 4,"userName": "中文测试-UserName-protobuf","userGroup": {"id": 4,"userGroupName": "中文测试-GroupName-protobuf"}}
'spring-redis-caching-with-protobuf' is distributed under the terms of the Apache Software Foundation license, version 2.0.