Giter VIP home page Giter VIP logo

j2cache's Introduction

参考j2cache实现的j2cache v1.0

======================两级缓存结构======================

  1. L1: 进程内缓存(ehcache) ,也可1级使用Redis,大多数项目的用法
  2. L2: 集中式缓存,支持多种集中式缓存服务器,如 Redis
  3. 由于大量的缓存读取会导致 L2 的网络带宽成为整个系统的瓶颈,因此 L1 的目标是降低对 L2 的读取次数

L1过期时不通知L2删除,L2手动删除时,通知其他L1进行删除操作。

==========key存储方式============ 以下两个方法为例:

  1. setn(region,key,value) //不通知其他节点清空消息
  2. set(region,key,value)
  3. set(key,value)

. 为了一个redis服务器,多个项目公用,key前缀添加namespace . region:为模块或者特定缓存,key:键,value:值 . region不设置时key=>"namespace:key" . redis,region不为空时存HASH: (“namespace:region”,“key”),region空时存String,key=>"namespace:key"

====================数据读取方法========================

  1. 读取顺序 -> L1 -> L2 -> DB
  2. 数据更新 1 从数据库中读取最新数据,依次更新 L1 -> L2 ,广播(定时)清除某个缓存信息 3.可指定读取的级别L1 or L2 4.可指定设定值的级别 L1 OR L2

====================什么时候可以用===========================

1.需要内存缓存和redis缓存同时使用的时候 2.需要使用redis的时候 3.需要设置定时过期的缓存的时候 4.多个类公用的内存缓存的时候(大多数情况用map就足够了)

====================注意事项================================

1.注意 因为redis hash 不能设置超时所以 有设置超时的自动设置为普通类型

2.不传region默认使用配置的默认缓存时间 (ehcache redis)

3.不想让其他节点清空消息的一定要使用setn方法

4.spring使用如果在bean初始化的时候就使用了 可能因为依赖redis没有初始化而失败 可以使用 depends-on="xxx" 解决

TODO

1.重新定义spring注解的使用方式更好支持j2cahce ?

2.解决高并发的 cache 穿透问题 (设置单线程定时刷新?)

j2cache's People

Contributors

jayqqaa12 avatar

Watchers

James Cloos 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.