大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

JVM内存级分布式缓存Hazelcast的应用

本篇内容主要讲解“JVM内存级分布式缓存Hazelcast的应用”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“JVM内存级分布式缓存Hazelcast的应用”吧!

十余年的澧县网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。网络营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整澧县建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“澧县网站设计”,“澧县网站推广”以来,每个客户项目都认真落实执行。

Hazelcast是一个内存分布式计算平台,用于管理数据并并行执行执行应用程序。

1. 它是用Java编写的。
2. 与其他一些内存数据库(如redis)不同,Hazelcast是多线程的,这意味着可从所有可用的CPU内核中受益。
3. 与其他内存数据网格不同 - 它设计用于分布式环境。它支持每个群集无限数量的map和缓存。

根据基准测试,Hazelcast在获取数据方面比Redis快56%,在设置数据方面比Redis快44%。

Hazelcast是一个高度可扩展的数据分发和集群平台。特性包括:

  1. 提供java.util.{Queue, Set, List, Map}分布式实现。

  2. 提供java.util.concurrency.locks.Lock分布式实现。

  3. 提供java.util.concurrent.ExecutorService分布式实现。

  4. 提供用于一对多关系的分布式MultiMap。

  5. 提供用于发布/订阅的分布式Topic(主题)。

  6. 通过JCA与J2EE容器集成和事务支持。

  7. 提供用于安全集群的Socket层加密。

  8. 支持同步和异步持久化。

  9. 通过JMX监控和管理集群。

  10. 支持动态HTTP Session集群。

  11. 利用备份实现动态分割。

  12. 支持动态故障恢复。

我们来看一下如何使用Hazelcast

pom

   com.hazelcast   hazelcast-all   3.10.1

在SpringBoot主程序开启缓存@EnableCaching

@EnableCaching@EnableFeignClients@EnableDiscoveryClient@EnableTransactionManagement@SpringBootApplicationpublic class ProductproviderApplication {   public static void main(String[] args) {
      ApplicationContext app = SpringApplication.run(ProductproviderApplication.class, args);      SpringBootUtil.setApplicationContext(app);   }

}

配置类

@Configurationpublic class HazelcastConfiguration {@Bean    public Config hazelCastConfig(){
        Config config = new Config();        config.setInstanceName("hazelcast-instance").addMapConfig(new MapConfig().setName("configuration").setMaxSizeConfig(new MaxSizeConfig(200,                        MaxSizeConfig.MaxSizePolicy.FREE_HEAP_SIZE)).setEvictionPolicy(EvictionPolicy.LFU)
                .setTimeToLiveSeconds(-1));        return config;    }
}

还是以昨天的汽车配件分类实体类来说明,此处注意一定要实现序列化接口Serializable

@AllArgsConstructor@NoArgsConstructorpublic class ProviderProductLevel implements Provider,Serializable {@Getter    @Setter    private Long id;    @Getter    @Setter    private String code;    @Getter    @Setter    private String name;    @Getter    @Setter    private Integer sort;    @Getter    @Setter    private Integer level;    @Getter    @Setter    private ProductType productType;    @Getter    @Setter    private String pictureUrl;    @Getter    @Setter    private List otherProperties;    @Getter    private List productListProviders = new CopyOnWriteArrayList<>();    public ProviderProductLevel(Long id,String code,String name,Integer sort,ProductType productType) {this.id = id;        this.code = code;        this.name = name;        this.sort = sort;        this.level = 1;        this.productType = productType;    }public ProviderProductLevel(Long id,String code,String name,Integer sort,String pictureUrl) {this.id = id;        this.code = code;        this.name = name;        this.sort = sort;        this.level = 2;        this.pictureUrl = pictureUrl;    }@Override    public boolean addProvider(Provider provider) {
        LevelDao levelDao = SpringBootUtil.getBean(LevelDao.class);        if (provider instanceof ProviderProductLevel) {
            levelDao.addLevelToLevel(new ParamLevel(this.id,((ProviderProductLevel)provider).getId()));        }return this.productListProviders.add(provider);    }}

写一个Controller,其中建立分布式缓存Map,不相关的内容不做解释,只说明分布式缓存内容

@Slf4j@RestControllerpublic class LevelController {//创建分布式缓存节点    private HazelcastInstance instance = Hazelcast.newHazelcastInstance();    @Autowired    private LevelDao levelDao;    //一级分类缓存//    private Map cachelevelMap1 = new ConcurrentHashMap<>();    private Map cachelevelMap1 = instance.getMap("level1");    /**     * 保存一级汽车配件分类     * @param level     * @return     */    @ProductAnnotation    @SuppressWarnings("unchecked")@Transactional    @PostMapping("/productprovider-anon/savelevel1")public Result saveLevel1(@RequestBody ProviderProductLevel level) {
        ProviderFactory.createProviderProductLevel1(level,true);        if (!cachelevelMap1.containsKey(level.getId())) {cachelevelMap1.put(level.getId(), level);        }return Result.success("保存成功");    }/**     * 保存二级汽车配件分类,并将二级产品分类添加到一级产品分类的子分类     * @param id     * @param level     * @return     */    @SuppressWarnings("unchecked")@Transactional    @PostMapping("/productprovider-anon/savelevel2")public Result saveLevel2(@RequestParam("id") Long id, @RequestBody ProviderProductLevel level) {
        ProviderFactory.createProviderProductLevel2(level,true);        if (cachelevelMap1.containsKey(id)) {//此处必须获取一级分类对象,再添加二级分类,然后重新放入缓存中            //直接使用cachelevelMap1.get(id).addProvider(level),将无法将            //level添加到CopyOnRightArrayList中            Provider level1 = cachelevelMap1.get(id);            level1.addProvider(level);            cachelevelMap1.put(id,level1);            log.info("缓存获取" + JSONObject.toJSONString(cachelevelMap1.get(id)));        }else {
            Provider level1 = levelDao.findLevel1(id);            log.info(JSONObject.toJSONString(level1));            level1.addProvider(level);            cachelevelMap1.put(id,level1);        }return Result.success("保存成功");    }@GetMapping("/productprovider-anon/getprovider")public Provider getProvider(@RequestParam("id") Long id) {return cachelevelMap1.get(id);    }
}

我们将端口号设为8106,并启动该端口的项目,我们可以看到这样一些日志

2019-07-10 10:19:38.381  INFO [productprovider,,,] 10216 --- [           main] com.hazelcast.instance.AddressPicker     : [LOCAL] [dev] [3.10.1] Prefer IPv4 stack is true.
2019-07-10 10:19:38.764  INFO [productprovider,,,] 10216 --- [           main] com.hazelcast.instance.AddressPicker     : [LOCAL] [dev] [3.10.1] Picked [192.168.192.15]:5702, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=5702], bind any local is true
2019-07-10 10:19:38.765  INFO [productprovider,,,] 10216 --- [           main] com.hazelcast.system                     : [192.168.192.15]:5702 [dev] [3.10.1] Hazelcast 3.10.1 (20180521 - 66f881d) starting at [192.168.192.15]:5702
2019-07-10 10:19:38.765  INFO [productprovider,,,] 10216 --- [           main] com.hazelcast.system                     : [192.168.192.15]:5702 [dev] [3.10.1] Copyright (c) 2008-2018, Hazelcast, Inc. All Rights Reserved.
2019-07-10 10:19:38.766  INFO [productprovider,,,] 10216 --- [           main] com.hazelcast.system                     : [192.168.192.15]:5702 [dev] [3.10.1] Configured Hazelcast Serialization version: 1
2019-07-10 10:19:38.766  INFO [productprovider,,,] 10216 --- [           main] com.hazelcast.instance.Node              : [192.168.192.15]:5702 [dev] [3.10.1] A non-empty group password is configured for the Hazelcast member. Starting with Hazelcast version 3.8.2, members with the same group name, but with different group passwords (that do not use authentication) form a cluster. The group password configuration will be removed completely in a future release.
2019-07-10 10:19:38.770  INFO [productprovider,,,] 10216 --- [           main] c.h.s.i.o.impl.BackpressureRegulator     : [192.168.192.15]:5702 [dev] [3.10.1] Backpressure is disabled
2019-07-10 10:19:38.770  INFO [productprovider,,,] 10216 --- [           main] h.s.i.o.i.InboundResponseHandlerSupplier : [192.168.192.15]:5702 [dev] [3.10.1] Running with 2 response threads
2019-07-10 10:19:39.422  INFO [productprovider,,,] 10216 --- [           main] com.hazelcast.instance.Node              : [192.168.192.15]:5702 [dev] [3.10.1] Creating MulticastJoiner
2019-07-10 10:19:39.428  INFO [productprovider,,,] 10216 --- [           main] c.h.s.i.o.impl.OperationExecutorImpl     : [192.168.192.15]:5702 [dev] [3.10.1] Starting 8 partition threads and 5 generic threads (1 dedicated for priority tasks)
2019-07-10 10:19:39.430  INFO [productprovider,,,] 10216 --- [           main] c.h.internal.diagnostics.Diagnostics     : [192.168.192.15]:5702 [dev] [3.10.1] Diagnostics disabled. To enable add -Dhazelcast.diagnostics.enabled=true to the JVM arguments.
2019-07-10 10:19:39.430  INFO [productprovider,,,] 10216 --- [           main] com.hazelcast.core.LifecycleService      : [192.168.192.15]:5702 [dev] [3.10.1] [192.168.192.15]:5702 is STARTING
2019-07-10 10:19:39.538  INFO [productprovider,,,] 10216 --- [           main] c.h.i.cluster.impl.MulticastJoiner       : [192.168.192.15]:5702 [dev] [3.10.1] Trying to join to discovered node: [192.168.192.15]:5701
2019-07-10 10:19:39.549  INFO [productprovider,,,] 10216 --- [cached.thread-3] com.hazelcast.nio.tcp.TcpIpConnector     : [192.168.192.15]:5702 [dev] [3.10.1] Connecting to /192.168.192.15:5701, timeout: 0, bind-any: true
2019-07-10 10:19:39.558  INFO [productprovider,,,] 10216 --- [thread-Acceptor] com.hazelcast.nio.tcp.TcpIpAcceptor      : [192.168.192.15]:5701 [dev] [3.10.1] Accepting socket connection from /192.168.192.15:4508
2019-07-10 10:19:39.561  INFO [productprovider,,,] 10216 --- [thread-Acceptor] c.h.nio.tcp.TcpIpConnectionManager       : [192.168.192.15]:5701 [dev] [3.10.1] Established socket connection between /192.168.192.15:5701 and /192.168.192.15:4508
2019-07-10 10:19:39.561  INFO [productprovider,,,] 10216 --- [cached.thread-3] c.h.nio.tcp.TcpIpConnectionManager       : [192.168.192.15]:5702 [dev] [3.10.1] Established socket connection between /192.168.192.15:4508 and /192.168.192.15:5701
2019-07-10 10:19:46.571  INFO [productprovider,,,] 10216 --- [ration.thread-0] c.h.internal.cluster.ClusterService      : [192.168.192.15]:5701 [dev] [3.10.1]

Members {size:2, ver:2} [
    Member [192.168.192.15]:5701 - 34da2d53-d8d6-4959-aaf2-bd6cda24f0fa this
    Member [192.168.192.15]:5702 - 70b959c7-ebb5-4226-b343-76e7354cbd94
]

2019-07-10 10:19:46.584  INFO [productprovider,,,] 10216 --- [ration.thread-0] com.hazelcast.system                     : [192.168.192.15]:5702 [dev] [3.10.1] Cluster version set to 3.10
2019-07-10 10:19:46.589  INFO [productprovider,,,] 10216 --- [ration.thread-0] c.h.internal.cluster.ClusterService      : [192.168.192.15]:5702 [dev] [3.10.1]

Members {size:2, ver:2} [
    Member [192.168.192.15]:5701 - 34da2d53-d8d6-4959-aaf2-bd6cda24f0fa
    Member [192.168.192.15]:5702 - 70b959c7-ebb5-4226-b343-76e7354cbd94 this
]

2019-07-10 10:19:47.568  INFO [productprovider,,,] 10216 --- [           main] com.hazelcast.core.LifecycleService      : [192.168.192.15]:5702 [dev] [3.10.1] [192.168.192.15]:5702 is STARTED

说明它打开了一个5702端口的分布式缓存系统

我们将Springboot的端口改成8006,并启动该端口的相同项目,我们可以在启动日志中看到

2019-07-10 10:23:16.328  INFO [productprovider,,,] 11764 --- [           main] com.hazelcast.instance.AddressPicker     : [LOCAL] [dev] [3.10.1] Prefer IPv4 stack is true.
2019-07-10 10:23:16.687  INFO [productprovider,,,] 11764 --- [           main] com.hazelcast.instance.AddressPicker     : [LOCAL] [dev] [3.10.1] Picked [192.168.192.15]:5704, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=5704], bind any local is true
2019-07-10 10:23:16.688  INFO [productprovider,,,] 11764 --- [           main] com.hazelcast.system                     : [192.168.192.15]:5704 [dev] [3.10.1] Hazelcast 3.10.1 (20180521 - 66f881d) starting at [192.168.192.15]:5704
2019-07-10 10:23:16.689  INFO [productprovider,,,] 11764 --- [           main] com.hazelcast.system                     : [192.168.192.15]:5704 [dev] [3.10.1] Copyright (c) 2008-2018, Hazelcast, Inc. All Rights Reserved.
2019-07-10 10:23:16.689  INFO [productprovider,,,] 11764 --- [           main] com.hazelcast.system                     : [192.168.192.15]:5704 [dev] [3.10.1] Configured Hazelcast Serialization version: 1
2019-07-10 10:23:16.689  INFO [productprovider,,,] 11764 --- [           main] com.hazelcast.instance.Node              : [192.168.192.15]:5704 [dev] [3.10.1] A non-empty group password is configured for the Hazelcast member. Starting with Hazelcast version 3.8.2, members with the same group name, but with different group passwords (that do not use authentication) form a cluster. The group password configuration will be removed completely in a future release.
2019-07-10 10:23:16.692  INFO [productprovider,,,] 11764 --- [           main] c.h.s.i.o.impl.BackpressureRegulator     : [192.168.192.15]:5704 [dev] [3.10.1] Backpressure is disabled
2019-07-10 10:23:16.692  INFO [productprovider,,,] 11764 --- [           main] h.s.i.o.i.InboundResponseHandlerSupplier : [192.168.192.15]:5704 [dev] [3.10.1] Running with 2 response threads
2019-07-10 10:23:17.310  INFO [productprovider,,,] 11764 --- [           main] com.hazelcast.instance.Node              : [192.168.192.15]:5704 [dev] [3.10.1] Creating MulticastJoiner
2019-07-10 10:23:17.315  INFO [productprovider,,,] 11764 --- [           main] c.h.s.i.o.impl.OperationExecutorImpl     : [192.168.192.15]:5704 [dev] [3.10.1] Starting 8 partition threads and 5 generic threads (1 dedicated for priority tasks)
2019-07-10 10:23:17.317  INFO [productprovider,,,] 11764 --- [           main] c.h.internal.diagnostics.Diagnostics     : [192.168.192.15]:5704 [dev] [3.10.1] Diagnostics disabled. To enable add -Dhazelcast.diagnostics.enabled=true to the JVM arguments.
2019-07-10 10:23:17.317  INFO [productprovider,,,] 11764 --- [           main] com.hazelcast.core.LifecycleService      : [192.168.192.15]:5704 [dev] [3.10.1] [192.168.192.15]:5704 is STARTING
2019-07-10 10:23:17.419  INFO [productprovider,,,] 11764 --- [           main] c.h.i.cluster.impl.MulticastJoiner       : [192.168.192.15]:5704 [dev] [3.10.1] Trying to join to discovered node: [192.168.192.15]:5701
2019-07-10 10:23:17.420  INFO [productprovider,,,] 11764 --- [cached.thread-3] com.hazelcast.nio.tcp.TcpIpConnector     : [192.168.192.15]:5704 [dev] [3.10.1] Connecting to /192.168.192.15:5701, timeout: 0, bind-any: true
2019-07-10 10:23:17.420  INFO [productprovider,,,] 11764 --- [cached.thread-3] c.h.nio.tcp.TcpIpConnectionManager       : [192.168.192.15]:5704 [dev] [3.10.1] Established socket connection between /192.168.192.15:4670 and /192.168.192.15:5701
2019-07-10 10:23:23.427  INFO [productprovider,,,] 11764 --- [ration.thread-2] com.hazelcast.system                     : [192.168.192.15]:5704 [dev] [3.10.1] Cluster version set to 3.10
2019-07-10 10:23:23.429  INFO [productprovider,,,] 11764 --- [ration.thread-2] c.h.internal.cluster.ClusterService      : [192.168.192.15]:5704 [dev] [3.10.1]

Members {size:4, ver:4} [
    Member [192.168.192.15]:5701 - 34da2d53-d8d6-4959-aaf2-bd6cda24f0fa
    Member [192.168.192.15]:5702 - 70b959c7-ebb5-4226-b343-76e7354cbd94
    Member [192.168.192.15]:5703 - 02829ed9-0ddf-4675-ba9e-15c1c03b4a50
    Member [192.168.192.15]:5704 - 6ecd17c1-425c-4be0-8914-827f51fdbf3e this
]

2019-07-10 10:23:23.431  INFO [productprovider,,,] 11764 --- [thread-Acceptor] com.hazelcast.nio.tcp.TcpIpAcceptor      : [192.168.192.15]:5704 [dev] [3.10.1] Accepting socket connection from /192.168.192.15:4674
2019-07-10 10:23:23.432  INFO [productprovider,,,] 11764 --- [thread-Acceptor] c.h.nio.tcp.TcpIpConnectionManager       : [192.168.192.15]:5704 [dev] [3.10.1] Established socket connection between /192.168.192.15:5704 and /192.168.192.15:4674
2019-07-10 10:23:23.436  INFO [productprovider,,,] 11764 --- [ration.thread-0] c.h.internal.cluster.ClusterService      : [192.168.192.15]:5703 [dev] [3.10.1]

Members {size:4, ver:4} [
    Member [192.168.192.15]:5701 - 34da2d53-d8d6-4959-aaf2-bd6cda24f0fa
    Member [192.168.192.15]:5702 - 70b959c7-ebb5-4226-b343-76e7354cbd94
    Member [192.168.192.15]:5703 - 02829ed9-0ddf-4675-ba9e-15c1c03b4a50 this
    Member [192.168.192.15]:5704 - 6ecd17c1-425c-4be0-8914-827f51fdbf3e
]

2019-07-10 10:23:23.437  INFO [productprovider,,,] 11764 --- [cached.thread-1] com.hazelcast.nio.tcp.TcpIpConnector     : [192.168.192.15]:5703 [dev] [3.10.1] Connecting to /192.168.192.15:5704, timeout: 0, bind-any: true
2019-07-10 10:23:23.438  INFO [productprovider,,,] 11764 --- [cached.thread-1] c.h.nio.tcp.TcpIpConnectionManager       : [192.168.192.15]:5703 [dev] [3.10.1] Established socket connection between /192.168.192.15:4675 and /192.168.192.15:5704
2019-07-10 10:23:23.438  INFO [productprovider,,,] 11764 --- [thread-Acceptor] com.hazelcast.nio.tcp.TcpIpAcceptor      : [192.168.192.15]:5704 [dev] [3.10.1] Accepting socket connection from /192.168.192.15:4675
2019-07-10 10:23:23.439  INFO [productprovider,,,] 11764 --- [thread-Acceptor] c.h.nio.tcp.TcpIpConnectionManager       : [192.168.192.15]:5704 [dev] [3.10.1] Established socket connection between /192.168.192.15:5704 and /192.168.192.15:4675
2019-07-10 10:23:23.440  INFO [productprovider,,,] 11764 --- [cached.thread-5] com.hazelcast.nio.tcp.TcpIpConnector     : [192.168.192.15]:5704 [dev] [3.10.1] Connecting to /192.168.192.15:5702, timeout: 0, bind-any: true
2019-07-10 10:23:23.444  INFO [productprovider,,,] 11764 --- [cached.thread-5] c.h.nio.tcp.TcpIpConnectionManager       : [192.168.192.15]:5704 [dev] [3.10.1] Established socket connection between /192.168.192.15:4676 and /192.168.192.15:5702
2019-07-10 10:23:23.444  INFO [productprovider,,,] 11764 --- [cached.thread-2] com.hazelcast.nio.tcp.TcpIpConnector     : [192.168.192.15]:5704 [dev] [3.10.1] Connecting to /192.168.192.15:5703, timeout: 0, bind-any: true
2019-07-10 10:23:23.447  INFO [productprovider,,,] 11764 --- [thread-Acceptor] com.hazelcast.nio.tcp.TcpIpAcceptor      : [192.168.192.15]:5703 [dev] [3.10.1] Accepting socket connection from /192.168.192.15:4677
2019-07-10 10:23:23.447  INFO [productprovider,,,] 11764 --- [cached.thread-2] c.h.nio.tcp.TcpIpConnectionManager       : [192.168.192.15]:5704 [dev] [3.10.1] Established socket connection between /192.168.192.15:4677 and /192.168.192.15:5703
2019-07-10 10:23:23.447  INFO [productprovider,,,] 11764 --- [thread-Acceptor] c.h.nio.tcp.TcpIpConnectionManager       : [192.168.192.15]:5703 [dev] [3.10.1] Established socket connection between /192.168.192.15:5703 and /192.168.192.15:4677
2019-07-10 10:23:24.422  INFO [productprovider,,,] 11764 --- [           main] com.hazelcast.core.LifecycleService      : [192.168.192.15]:5704 [dev] [3.10.1] [192.168.192.15]:5704 is STARTED

我们先在8006端口的进程中添加一个一级配件

JVM内存级分布式缓存Hazelcast的应用

2019-07-10 10:23:43.408 DEBUG [productprovider,7c69f637b05303a0,7c69f637b05303a0,false] 11764 --- [nio-8006-exec-1] c.c.p.d.L.saveProviderProductLevel1      : ==>  Preparing: insert into product_level (id,code,name,sort,level,product_type) values (?,?,?,?,?,?)
2019-07-10 10:23:43.431 DEBUG [productprovider,7c69f637b05303a0,7c69f637b05303a0,false] 11764 --- [nio-8006-exec-1] c.c.p.d.L.saveProviderProductLevel1      : ==> Parameters: 2459048597577007931(Long), 10003(String), 汽车项链(String), 3(Integer), 1(Integer), 车品(String)
2019-07-10 10:23:43.454 DEBUG [productprovider,7c69f637b05303a0,7c69f637b05303a0,false] 11764 --- [nio-8006-exec-1] c.c.p.d.L.saveProviderProductLevel1      : <==    Updates: 1

然后我们在8106端口进程中添加一个二级汽车配件分类,我们来看一看是否可以获取一级配件分类的缓存

JVM内存级分布式缓存Hazelcast的应用

根据日志打印

2019-07-10 10:26:02.587 DEBUG [productprovider,deca9b0c23fc065f,deca9b0c23fc065f,false] 10216 --- [nio-8106-exec-1] c.c.p.d.L.saveProviderProductLevel2      : ==>  Preparing: insert into product_level (id,code,name,sort,level,picture_url) values (?,?,?,?,?,?)
2019-07-10 10:26:02.613 DEBUG [productprovider,deca9b0c23fc065f,deca9b0c23fc065f,false] 10216 --- [nio-8106-exec-1] c.c.p.d.L.saveProviderProductLevel2      : ==> Parameters: 2459048746827121467(Long), 100201(String), 高级项链(String), 1(Integer), 2(Integer), sdfasgfd23dg(String)
2019-07-10 10:26:02.635 DEBUG [productprovider,deca9b0c23fc065f,deca9b0c23fc065f,false] 10216 --- [nio-8106-exec-1] c.c.p.d.L.saveProviderProductLevel2      : <==    Updates: 1
2019-07-10 10:26:02.664  INFO [productprovider,deca9b0c23fc065f,deca9b0c23fc065f,false] 10216 --- [nio-8106-exec-1] c.c.p.controller.LevelController         : 缓存获取{"code":"10003","id":2459069885582410555,"level":1,"name":"汽车项链","productListProviders":[{"code":"100201","id":2459069910278472507,"level":2,"name":"高级项链","pictureUrl":"sdfasgfd23dg","productListProviders":[],"sort":1}],"productType":"TYPE2","sort":3}
2019-07-10 10:26:02.666 DEBUG [productprovider,deca9b0c23fc065f,deca9b0c23fc065f,false] 10216 --- [nio-8106-exec-1] c.c.p.dao.LevelDao.addLevelToLevel       : ==>  Preparing: update product_level set parent_id=? where id=?
2019-07-10 10:26:02.666 DEBUG [productprovider,deca9b0c23fc065f,deca9b0c23fc065f,false] 10216 --- [nio-8106-exec-1] c.c.p.dao.LevelDao.addLevelToLevel       : ==> Parameters: 2459048597577007931(Long), 2459048746827121467(Long)
2019-07-10 10:26:02.689 DEBUG [productprovider,deca9b0c23fc065f,deca9b0c23fc065f,false] 10216 --- [nio-8106-exec-1] c.c.p.dao.LevelDao.addLevelToLevel       : <==    Updates: 1

如果此处一级配件是从数据库中查出来的,那么此处的日志将不会有缓存获取4个字,说明该缓存已经同步到了不同进程中。

到此,相信大家对“JVM内存级分布式缓存Hazelcast的应用”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!


名称栏目:JVM内存级分布式缓存Hazelcast的应用
网址分享:http://dzwzjz.com/article/jgcdsd.html
在线咨询
服务热线
服务热线:028-86922220
TOP