Giter Club home page Giter Club logo

easycache's Introduction

EasyCache

简介

对远程缓存(Redis)和本地缓存(Caffeine)的封装, 实现轻量级的多级缓存框架;

使用示例

快速入门

1. 导入依赖和配置

<dependency>
    <groupId>org.galileo.easycache</groupId>
    <artifactId>easycache-cli-boot-starter</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>
# SpringDataRedis 配置
spring.redis.host=127.0.0.1
spring.redis.port=6379
#spring.redis.password=
spring.redis.database=1
spring.redis.timeout=10s
spring.redis.jedis.pool.min-idle=4
spring.redis.jedis.pool.max-idle=20
spring.redis.jedis.pool.max-active=100
spring.redis.jedis.pool.max-wait=10000

# easyCache 配置
easycache.enabled=true
easycache.ns.dft.type=both
easycache.ns.dft.remote.type=redis#spring.redis-org.springframework.boot.autoconfigure.data.redis.RedisProperties

2. 使用注解

    // 开启缓存
    @EnableEasyCache(basePackages = "org.easycachetestlocal")


    @Cached(cacheName = "user", key = "#id")
    public UserDO get(int id) {
        return userDAO.selectById(id);
    }

    @CacheRemove(cacheName = "user", key = "#id")
    public void del(int id) {
        userDAO.deleteById(id);
    }

    @CacheUpdate(cacheName = "user", key = "#userDO.id", consistency = ConsistencyType.EVENTUAL)
    public UserDO update(UserDO userDO) {
        if (userDAO.updateById(userDO) > 0) {
            return userDO;
        }
        return null;
    }

3. 使用API

EasyCacheUtils.put(namespace, cacheName, key, userDO, 100 * 1000);
UserDO userDO1 = EasyCacheUtils.get(namespace, cacheName, key, UserDO.class);

特点

  • 支持注解+API
  • 支持多级缓存(默认远程Redis, 本地Caffeine)
  • 支持bigkey检测和过滤
  • 远程缓存失败, 可容错降级成本地缓存
  • 支持多namespace, 多组远程+本地的配置
  • 支持配置动态更新生效(绝大多数配置, 在SpringCloud环境下)
  • 支持缓存管理(规划中)
  • 支持缓存监控(规划中)

更多支持开发中..., 欢迎参与建设

TODO

  • 分布式锁
  • redis 客户端支持
  • 管理后台监控

打包

# 打包
mvn package -Dmaven.test.skip=true

# 安装到仓库
mvn install -Dmaven.test.skip=true

Contributing

欢迎参与项目贡献!比如提交PR修复一个bug,或者新建 Issue 讨论新特性或者变更。

Copyright and License

产品开源免费,并且将持续提供免费的社区技术支持。个人或企业内部可自由的接入和使用。如有需要可邮件联系作者免费获取项目授权。

easycache's People

Contributors

noseew avatar qincasin avatar

Stargazers

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