Code Monkey home page Code Monkey logo

cache-service's Introduction

cache-service

Development Environment

OS
ProductName:	macOS
ProductVersion:	12.0
Gopath
GOPATH="/Users/minhtet/go"
local repo dir
/Users/minhtet/dev/cache-service

Setup

  1. Clone the Rep
  2. Start Redis server
    chmod +x initialize_redis.sh && ./initialize_redis.sh
  3. build server
    go build -o ./build/rpcServer ./server/handlers/*.go
  4. build client
    go build -o ./build/rpcClient ./client/*.go

Usage

Programming interface

1. Set Cache
var ctx = context.Background()
_, err := c.Set(ctx, &pb.CacheSetInput{Key: "hello", Value: []byte("123")})
if err != nil {
	panic(err)
}
2. Get Cache
var ctx = context.Background()
resp, err := c.Get(ctx, &pb.CacheGetInput{Key: "hello"})
if err != nil {
	panic(err)
}
fmt.Println(resp)
3. Set User Cache
_, err = c.SetUser(ctx, &pb.User{
	Name:     "john",
	Class:    "V",
	Rollnum:  22,
	Metadata: []byte("smart student"),
})
if err != nil {
	panic(err)
}
4. Get User Cache
user, err := c.GetUser(ctx, &pb.GetUserInput{
		Name:    "john",
		Class:   "V",
		Rollnum: 22,
})
if err != nil {
	panic(err)
}

fmt.Println(user)

Console

1. Run server

./build/rpcServer

2. Set Cache

./build/rpcClient -set your_key your_value

3. Get Cache

./build/rpcClient -get your_key

4. Set User Cache

./build/rpcClient -set-user john V 22 "smart student"

5. Get User Cache

./build/rpcClient -get-user john V 22

cache-service's People

Contributors

minhtet-o avatar

Stargazers

Pyae Phyo Hlaing avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.