Code Monkey home page Code Monkey logo

Comments (3)

dantefung avatar dantefung commented on July 18, 2024
  1. 实现SerialPolicy接口
    比如 TestPolicy

  2. 注册Bean
    @bean(name = "testPolicy")
    public SerialPolicy testPolicy() {
    // 省略
    return testPolicy;
    }

  3. 配置 ,格式:valueEncoder: bean:testPolicy
    jetcache:
    statIntervalMinutes: 15
    areaInCacheName: false
    local:
    default:
    type: linkedhashmap
    keyConvertor: fastjson
    remote:
    test:
    type: redisson
    valueEncoder: bean:testPolicy
    valueDecoder: bean:testPolicy

from jetcache.

dantefung avatar dantefung commented on July 18, 2024

我还是想用fastjson2进行value的序列化和反序列化,但是想存redis之前对value进行gzip压缩,减小数据的体积。但是看了看文档没有找到自定义序列化和反序列化的完整代码。麻烦给个步骤。 同时也问问有没有人是用gzip压缩的。效果好不好。不考虑kryo的原因是 如果新增 减少字段 kryo会报错。

源码参见:
com.alicp.jetcache.autoconfigure.JetCacheAutoConfiguration#springConfigProvider
com.alicp.jetcache.anno.support.SpringConfigProvider
com.alicp.jetcache.anno.support.DefaultSpringEncoderParser
com.alicp.jetcache.anno.support.DefaultSpringEncoderParser#parseBeanName

com.alicp.jetcache.anno.support.ConfigProvider#doInit

from jetcache.

wyc9512 avatar wyc9512 commented on July 18, 2024

api模式:
//初始化任务图相关数据的缓存配置
QuickConfig graphQc = QuickConfig.newBuilder(JetCacheConstant.PUBLISH_GRAPH_CACHE_NAME)
.expire(Duration.ofDays(PUBLISH_DATA_EXPIRE_TIME))
.cacheType(CacheType.BOTH)
// 本地缓存更新后,将在所有的节点中删除缓存,以保持强一致性
.valueDecoder(bytes -> GzipUtils.unGzip(new String(bytes, StandardCharsets.UTF_8)))
.valueEncoder(obj -> {
String gzip = GzipUtils.gzip(JSONObject.toJSONString(obj));
return gzip.getBytes();
})
.syncLocal(false)
.build();
使用起来感觉还行

from jetcache.

Related Issues (20)

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.