Giter VIP home page Giter VIP logo

lightkv's Introduction

lightkv 轻量化key-value服务

启动server

go run main/server.go  

启动测试rpc客户端

  go run main/client.go  

rpc 客户端用法

c := server.NewClient()
c.Start()

//添加kv
c.Put("test", "test_value", 0)
c.Put("test1/tttt", "test1_value", 0)
c.Put("test2", "test2_value", 20)

//删除kv
c.Del("test")

v := c.Get("test2")
fmt.Printf("test2:%s\n", v)

//监听key值,发生变化回调通知  
c.WatchKey("watch1", func(k string, v string, t cache.OpType) {
  fmt.Printf("watch key:%s, value:%s, type:%d\n", k, v, t)
})
  
//key值发生变化回调通知  
c.WatchKey("unwatch", func(k string, v string, t cache.OpType) {
  fmt.Printf("watch key:%s, value:%s, type:%d\n", k, v, t)
})

//取消监听key值的变化  
c.UnWatchKey("unwatch")  
c.Close()

lightkv's People

Contributors

llr104 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.