Our use case includes clearing the cache at the end of the day and
repopulating it with new content. With a size of the cache in 1.5M records
cache.clear() works extremely slowly and we use cache.destroy(), creating a
new cache and populating it with a new content. As this works as long as all
the cache content is in memory, in case of having an EvictionPolicy defined
for the cache that specifies sizeMax and the cache content exceeds this
size, any attempt of repopulating the new cache fails with
CachePartialUpdateException: Failed to update keys

//Below is the unit test: 
                IgniteCache<WorkspaceItemKey, WorkspaceItem> cache =
igniteNode.cache("workspace");
                WorkspaceDao workspaceDao = new WorkspaceDaoImpl(cache);
                Long workspaceId = 1L;
                List<AbstractAuditable&lt;Long>> objects = 
createTestObjects(100);
                workspaceDao.insertItems(workspaceId, objects); //uses 
cache.putAll();
                
                CacheConfiguration cacheCfg = new
CacheConfiguration(cache.getConfiguration(CacheConfiguration.class));
                
                cache.destroy();
                
                cache = null;
                try {
                        cache = igniteNode.getOrCreateCache(cacheCfg);
                        System.out.println("Closed=" + cache.isClosed());
        
                        workspaceDao = new WorkspaceDaoImpl(cache);
                        workspaceDao.insertItems(workspaceId, objects); //uses 
cache.putAll();
                } catch (Exception e) {
                        throw e;
                }
                System.out.println("Inserted");
//Cache configuration:
                <bean parent="agg-cache">
                    <property name="name" value="workspace"/>
                    <property name="indexedTypes">
                        <list>
                  
<value>au.com.macquarie.rmg.aggengine.service.workspace.domain.WorkspaceItemKey</value>
                        
<value>au.com.macquarie.rmg.aggengine.service.workspace.domain.WorkspaceItem</value>
                        </list>
                    </property>
                    <property name="evictionPolicy">
                        <bean
class="org.apache.ignite.cache.eviction.lru.LruEvictionPolicy">
                            <property name="maxSize" value="100"/>
                        </bean>
                    </property>
                </bean>




--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Cannot-recreate-cache-after-cache-destroy-tp7291.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Reply via email to