[ 
https://issues.apache.org/jira/browse/IGNITE-11141?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16757028#comment-16757028
 ] 

Moldachev Sergey commented on IGNITE-11141:
-------------------------------------------

[~slukyanov] The IgniteKernal has GridKernalContext ctx with cache() method 
which return GridCacheProcessor by which I can get the CacheConfig by template 
name. Could you please review a simple implementation?
{code:java}
CacheConfiguration ccfg = ctx.cache().getConfigFromTemplate(cacheName);
if (ccfg == null) {
     return cache(cacheName).getConfiguration(CacheConfiguration.class);
} else {
     return ccfg;
}
{code}

Thank you!

> Add Java method to create a cache from a template
> -------------------------------------------------
>
>                 Key: IGNITE-11141
>                 URL: https://issues.apache.org/jira/browse/IGNITE-11141
>             Project: Ignite
>          Issue Type: Task
>            Reporter: Stanislav Lukyanov
>            Assignee: Moldachev Sergey
>            Priority: Major
>              Labels: newbie
>
> Currently cache templates can only be used via REST or SQL: 
> https://apacheignite.readme.io/docs/cache-template.
> It seems reasonable to add the same functionality to Java.
> The most flexible way would probably be to add a method like 
> `cacheConfiguration(String)` that would return a configuration of a template 
> with the given name. Then to create a cache from a template one would write 
> code like this
> {code}
> CacheConfiguration cfg = ignite.cacheConfiguration("myTemplate");
> cfg.setName("myCacheFromTemplate");
> ignite.createCache(cfg);
> {code}
> As a bonus, the `cacheConfiguration(String)` method may work with regular 
> caches too. For them it would be a shortcut for 
> `ignite.cache("myCache").getConfiguration()`.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to