首页 > 解决方案 > Apache Ignite:我的数据是从内存还是磁盘读取的?

问题描述

我需要了解 Ignite 的以下配置是否将从内存或磁盘提供我的数据。

点燃配置:

<property name="dataStorageConfiguration">
    <bean class="org.apache.ignite.configuration.DataStorageConfiguration">
        <property name="defaultDataRegionConfiguration">
            <bean class="org.apache.ignite.configuration.DataRegionConfiguration">
                <property name="persistenceEnabled" value="true"/>
            </bean>
        </property>
    </bean>
</property>

Java 代码:

ClientConfiguration cfg = new ClientConfiguration().setAddresses("127.0.0.1:10800");
try (IgniteClient client = Ignition.startClient(cfg)) {
    ClientCache<Long, SensorsWaiting> cache = client.cache("SQL_PUBLIC_FOO");
    FieldsQueryCursor<List<?>> query = cache.query(new SqlFieldsQuery("select * from foo"));
}

问题的背景:我预计会有大量查询,并且需要从内存中提供结果。同时我需要将数据存储到磁盘以防 Ignite Server 崩溃或需要重新启动。

标签: spring-bootignite

解决方案


如果它在内存中,它将从内存中提供,否则将从磁盘中提取。(如果数据多于内存或集群启动时,这种区别很重要。)

不同的 API 都访问相同的数据。无论您使用 JCache(get、put)、SqlFieldsQuery 还是 JDBC/ODBC,都一样。


推荐阅读