Coder Social home page Coder Social logo

autocache's Introduction

autoCache

概述

autoCache是一个Java轻量级的二级缓存组件。首先,autoCache 本身并无缓存功能,而是利用内存缓存caffeine和高性能数据库Redis,实现的二级缓存组件。 autoCache 解决高并发场景时缓存逻辑复杂的问题,以极简的方式实现缓存功能,提升系统性能、开发效率。

基本要求

  1. JDK 1.8+
  2. Spring boot 2.0+
  3. 添加依赖
<dependency>
  <groupId>io.github.haozi2015</groupId>
  <artifactId>autocache-spring-boot-starter</artifactId>
  <version>1.0.4</version>
</dependency>

使用说明

方法使用@AutoCache注解,即完成方法的参数和结果缓存。

    // 仅用本地缓存,5秒后过期
    @AutoCache(localTTL = 5)
    String getLocalStr() {
        return "abc";
    }

    // 仅用远程缓存
    @AutoCache(remoteTTL = 30)
    String getRemoteStr() {
        return "abc";
    }
            
    // 二级缓存
    // 优先本地缓存,不存在时查远程缓存,不存在是调用原方法,结果再依次被远程和本地缓存
    // 分别本地缓存5秒过期,远程缓存30秒过期
    @AutoCache(localTTL = 5, remoteTTL = 30)
    String getStr() {
        return "abc";
    }

远程缓存,配置Redis同SpringBoot方式。

更多功能

完整代码,参考demo

TODO

  1. 主动缓存功能
  2. 监控,访问量、命中率、miss率等
  3. 内存缓存的一致性问题

autocache's People

Contributors

haozi2015 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

wuhuaroubj

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.