本文介绍了使用Hazelcast在磁盘上保留数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了HazelCast 2.5.我想将我的记录保存到磁盘中.我了解到MapStore可以完成这项工作.但是我不确定如何实现MapStore.

I have installed HazelCast 2.5. I want to persist my records into disk. I learned that MapStore does this job. However i'm not sure how to implement MapStore.

到目前为止我写的代码:

Code I've written so far:

public class MyMaps implements MapStore<String,String> {

    public static Map<Integer, String> mapCustomers = Hazelcast.getMap("customers");

    public static void main(String[] args) {
        {
            mapCustomers.put(1, "Ram");
            mapCustomers.put(2, "David");
            mapCustomers.put(3, "Arun");

        }
    }
}

如何将所有这些条目放入磁盘.

How do i put all these entries into disk.

是否需要像MySQL或PostgreSQL这样的后端才能使用此类?

Is it necessary to have a back-end like MySQL or PostgreSQL to use this class?

我相信可以使用以下功能:

I believe the following function can be used:

public void delete(String arg0);
public void deleteAll(String arg0);
public void store(String arg0);
public void storeAll(String arg0);

我需要一个有关如何实现MapStore的样本片段.

I need a sample snippet of how to implement MapStore.

请向我提供示例代码.

推荐答案

就其分区策略而言,Hazelcast具有两种类型的分布式对象:

Hazelcast has two types of distributed objects in terms of their partitioning strategies:

  • 每个分区存储一部分实例的数据结构,即分区的数据结构.

  • Data structures where each partition stores a part of the instance, namely partitioned data structures.

单个分区存储整个实例的数据结构,即未分区的数据结构.

Data structures where a single partition stores the whole instance, namely non-partitioned data structures.

不支持将分区的Hazelcast数据结构的持久性数据存储到本地文件系统,需要一个可从所有hazelcast成员(如mysql或mongodb)访问的集中式系统.

Partitioned Hazelcast data structures persistence data to local file system is not supported,need a centralized system that is accessible from all hazelcast members,like mysql or mongodb.

您可以从 hazelcast-code-samples .

这篇关于使用Hazelcast在磁盘上保留数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 10:41