Apache Ignite 2.16 - 使用瘦客户端动态创建缓存的事务的 C++ 支持

问题描述 投票:0回答:1

您好 ApacheIgnite 团队,

我计划使用 C++ 瘦客户端创建动态缓存,并希望将事务用于某些操作。 C++ 瘦客户端中是否有规定将 Automicity 模式的缓存配置设置为事务性?

ignite::thin::IgniteClientConfiguration cfg;
cfg.SetEndPoints("10.1.53.61:10800");
cfg.SetPartitionAwareness(true);
m_igniteClient = ignite::thin::IgniteClient::Start(cfg);
ignite::thin::cache::CacheClient<int16_t, std::string> client =
    m_igniteClient.GetOrCreateCache<int16_t, std::string>(cacheName.c_str());

IgniteClientConfiguration 或 ignite::thin::IgniteClient 没有任何 API 来设置自动模式。

请注意,缓存是使用瘦客户端 C++ 动态创建的。

有没有其他方法可以使用瘦客户端C++实现交易?

ignite apacheignite
1个回答
0
投票

您可以在服务器上定义缓存模板 [1],并使用它从 C++ 瘦客户端动态创建缓存

  1. 在服务器上使用带星号
    *
    的缓存配置 - 缓存不会启动,但会创建一个模板
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
    <property name="cacheConfiguration">
        <list>
            <bean abstract="true" class="org.apache.ignite.configuration.CacheConfiguration" id="cache-template-bean">
                <!-- when you create a template via XML configuration, you must add an asterisk to the name of the template -->
                <property name="name" value="tx-cache-*"/>
                <property name="atomicity" value="TRANSACTIONAL"/>
                <!-- Other cache parameters -->
            </bean>
        </list>
    </property>
</bean>
  1. 在C++中使用相应的名称前缀启动缓存
// Create transactional cache from template
auto cache = m_igniteClient.GetOrCreateCache<int16_t, std::string>(
    "tx-cache-foobar1");

[1] https://ignite.apache.org/docs/latest/configuring-caches/configuration-overview#cache-templates

© www.soinside.com 2019 - 2024. All rights reserved.