GithubHelp home page GithubHelp logo

dcache's Introduction

dCache

dCache 是一个基于 Go 开发的分布式缓存系统, 是一个开箱即用的 server 组件
使用 Go + gRPC + etcd + singleFlight

Features

Installation

  • 构建
make run
  • 测试
    • 测试前确保本地已启动 etcd 服务
    • docker run --name etcd -p 2379:2379 -e ALLOW_NONE_AUTHENTICATION=yes -d binami/etcd:latest
make test
  • 使用:
    借助 Go Modules 然后:
import "github.com/peanutzhen/peanutcache"

接口

  • dCache 通过封装 Group 对外提供服务
    • 提供两个接口
      • Get: 从缓存中获取值
      • Update:先删除数据库,再删除缓存,保证缓存与数据库之间的一致性
    • Group 也是命名空间, 不同的命名空间之间是相互隔离的

性能分析

  • 测试代码见example
  • 测试环境:
    • CPU: Intel(R) Core(TM) i5-9300H CPU @ 2.40GHz
    • GPU: NVIDIA GeForce GTX 1660Ti
    • 内存: 8G+8G
    • 内核版本: 6.5.9-arch2-1
  • 在缓存均命中的情况下, go test -bench=".*" 的结果如下:
  719850	      1545 ns/op
PASS
ok  	github.com/Daz-3ux/dazCache/example/benchMark	1.135s
  • 缓存均命中情况下: perf 测试结果如下
    • 使用 make perf 进行测试
 Performance counter stats for '/home/realdaz/z-project/dCache/example/perf/perfTest':

            283.35 msec task-clock:u                     #    1.026 CPUs utilized
                 0      context-switches:u               #    0.000 /sec
                 0      cpu-migrations:u                 #    0.000 /sec
             1,518      page-faults:u                    #    5.357 K/sec
       348,824,662      cycles:u                         #    1.231 GHz
       538,245,341      instructions:u                   #    1.54  insn per cycle
       106,920,921      branches:u                       #  377.352 M/sec
         1,020,084      branch-misses:u                  #    0.95% of all branches

       0.276101514 seconds time elapsed

       0.069122000 seconds user
       0.213862000 seconds sys

流程

                            是
接收 key --> 检查是否被缓存 -----> 返回缓存值 ⑴
                |  否                         是
                |-----> 是否应当从远程节点获取 -----> 与远程节点交互 --> 返回缓存值 ⑵
                            |  否
                            |-----> 调用`回调函数`,获取值并添加到缓存 --> 返回缓存值 ⑶

License

MIT

dcache's People

Contributors

daz-3ux avatar

Stargazers

 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.