GithubHelp home page GithubHelp logo

redis-counter-1's Introduction

redis-counter

基于redis的实时计数器,可用于点赞等单个统计场景

实现逻辑

1.将数据分为两部分,数据库取出的DBData、redis中的kv计数counter
2.增加计数时,incr操作redis中的计数
3.取回计数时,取DBData(同时缓存) + counter
4.更新counter到db时,将counter利用getset置为0,然后清空DBData缓存(这个地方会有短暂的数据不一致,但是影响不大,可以通过其他方式处理,比如给一个中间状态的key取一个固定的值,更新完成后删除这个key)
5.更新方式有定时扫描更新、设定超过伐值更新2种

redis-counter-1's People

Contributors

hailin0 avatar

Stargazers

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