ProductName: macOS
ProductVersion: 12.0
GOPATH="/Users/minhtet/go"
/Users/minhtet/dev/cache-service
- Clone the Rep
- Start Redis server
chmod +x initialize_redis.sh && ./initialize_redis.sh
- build server
go build -o ./build/rpcServer ./server/handlers/*.go
- build client
go build -o ./build/rpcClient ./client/*.go
var ctx = context.Background()
_, err := c.Set(ctx, &pb.CacheSetInput{Key: "hello", Value: []byte("123")})
if err != nil {
panic(err)
}
var ctx = context.Background()
resp, err := c.Get(ctx, &pb.CacheGetInput{Key: "hello"})
if err != nil {
panic(err)
}
fmt.Println(resp)
_, err = c.SetUser(ctx, &pb.User{
Name: "john",
Class: "V",
Rollnum: 22,
Metadata: []byte("smart student"),
})
if err != nil {
panic(err)
}
user, err := c.GetUser(ctx, &pb.GetUserInput{
Name: "john",
Class: "V",
Rollnum: 22,
})
if err != nil {
panic(err)
}
fmt.Println(user)
./build/rpcServer
./build/rpcClient -set your_key your_value
./build/rpcClient -get your_key
./build/rpcClient -set-user john V 22 "smart student"
./build/rpcClient -get-user john V 22