[MGNLCACHE-55] Caching arbitrary objects Created: 14/Mar/14  Updated: 15/Dec/16  Resolved: 13/Aug/14

Status: Closed
Project: Cache Modules
Component/s: configuration
Affects Version/s: None
Fix Version/s: 5.4

Type: Improvement Priority: Major
Reporter: Magnolia International Assignee: Roman Kovařík
Resolution: Fixed Votes: 0
Labels: m2
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: Not Specified Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Issue Links:
Relates
relates to MGNLCACHE-66 Explicitly prevent an Ehcache named "... Closed
causality
is causing MGNLCAT-138 Update cache-related update tasks to ... Closed
is causing MGNLSTK-1421 Update cache-related update tasks to ... Closed
dependency
depends upon MAGNOLIA-5263 Allow specifying transformer via @Tra... Closed
is depended upon by MGNLCACHE-78 Move store caching configuration into... Closed
relation
is related to MGNLCACHE-72 Update cache-related update tasks to ... Closed
is related to MGNLCACHE-32 Upgrade Ehcache to the latest (2.10.0) Closed
is related to MGNLCACHE-75 Make it possible to share default con... Closed
Sub-Tasks:
Key
Summary
Type
Status
Assignee
MGNLCACHE-59 Update tasks for default cache config... Sub-task Closed Magnolia International  
MGNLCACHE-70 Change flush policy workspace registr... Sub-task Closed Roman Kovařík  
MGNLCACHE-71 Rename CacheFilter#cacheConfig to #co... Sub-task Closed Roman Kovařík  
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Release notes required:
Yes
Date of First Response:

 Description   

The current cache module is very biased towards caching pages (or request/responses in general).

We've already abused it to cache uuid mappings, and it'd be beneficial to do this for other things too (personalization could use it, forum, ...)

With our current API, one can get an arbitrary cache object by name, but that comes with FlushStrategy, etc, which are very likely irrelevant. Besides this unnecessary API leak, it is currently impossible to configurable such an arbitrary cache's underlying cache (i.e, for example, use different sizes and eviction mechanisms) - we can currently only configure the "defaultCacheFactory".

http://wiki.magnolia-cms.com/display/DEV/Concept+-+Cache+arbitrary+objects



 Comments   
Comment by Magnolia International [ 14/Mar/14 ]

MGNLCACHE-32 and MGNLCACHE-55 could perhaps be tackled together; I don't think there is an actual dependency between the 2 changes, but we should definitely look at both issues to make we're not going to make one or the other more difficult to implement.

Comment by Magnolia International [ 19/May/14 ]

Caching arbitrary object implies we'd want multiple configurations. Unfortunately, with the current ehcache version we use, we have to use a transformer for net.sf.ehcache.config.CacheConfiguration because of how memoryStoreEvictionPolicy's setter methods doesn't respect javabeans naming conventions. I'm hoping newer versions of EhCache have fixed this (but they have introduced other hurdles for us - see MGNLCACHE-32).

This goes hand in hand with renaming our current CacheConfiguration object to something like PageCacheConfiguration (this is the cache/flush policy config).

Comment by Magnolia International [ 23/May/14 ]

We can solve one of the node2bean issues by subclassing net.sf.ehcache.config.CacheConfiguration (and thus being able to use our converter on a map of EhCacheConfigurations)

Comment by Magnolia International [ 04/Jun/14 ]

Pushed to feature/cache-arbitrary-objects branch. Some TODOs left:

  • verify what happens with cache entries after a restart (TBV because we explicitly "add" caches. Verify with both an explicitly configured cache and one relying on default settings)
  • check construction of caches and CacheManager, e.g use CacheManager.newInstance instead ?
Comment by Magnolia International [ 13/Aug/14 ]

Pushed to feature/cache-arbitrary-objects-2 branch

Comment by Roman Kovařík [ 13/Aug/14 ]
/Users/romankovarik/projects/master/cache/src/main/java/info/magnolia/module/cache/CacheConfiguration.java:36: Javadoc has empty description section.
/Users/romankovarik/projects/master/cache/src/main/java/info/magnolia/module/cache/ehcache/EhCacheConfiguration.java:38:8: Unused import - net.sf.ehcache.config.PersistenceConfiguration.
/Users/romankovarik/projects/master/cache/src/main/java/info/magnolia/module/cache/ehcache/EhCacheConfiguration.java:64: First sentence should end with a period.
/Users/romankovarik/projects/master/cache/src/test/java/info/magnolia/module/cache/filter/BlockingCacheTest.java:76:8: Unused import - java.util.Map.
info.magnolia.objectfactory.NoSuchComponentException: No component configuration for type [info.magnolia.module.cache.ehcache.EhCacheConfigurationTransformer] found. Please add a configuration to your module descriptor.
java.lang.NullPointerException
	at info.magnolia.module.cache.filter.CacheFilter.onCacheModuleStart(CacheFilter.java:111)

info.magnolia.module.cache.ehcache.EhCacheFactoryTest.canUseDifferentCacheConfigPerNamedCache(): I don't get the description :
assertEquals("7 was configured explicitly for cache2", MemoryStoreEvictionPolicy.FIFO, getEvictionStrategy(factory, "cache-2"));

Comment by Roman Kovařík [ 13/Aug/14 ]

For follow-up tickets:

Create tickets for update of modules to reflect new cache settings:
[INFO] [talledLocalContainer] 2014-08-13 11:00:09,057 ERROR info.magnolia.module.InstallContextImpl           : > Could not create property contacts at /modules/cache/config/configurations/default/flushPolicy/policies/flushAll/repositories, please create it with value contacts.
[INFO] [talledLocalContainer] 2014-08-13 11:00:10,648 ERROR info.magnolia.module.InstallContextImpl           : > Could not create property dam at /modules/cache/config/configurations/default/flushPolicy/policies/flushAll/repositories, please create it with value dam.
[INFO] [talledLocalContainer] 2014-08-13 11:00:19,119 ERROR info.magnolia.module.InstallContextImpl           : > Could not install or update standard-templating-kit module. Task 'Browser cache policy' failed. (ItemNotFoundException: node /modules/cache/config/configurations/default/browserCachePolicy/policies has no child node with name default)
[INFO] [talledLocalContainer] 2014-08-13 11:00:19,661 ERROR info.magnolia.module.InstallContextImpl           : > Could not create property category at /modules/cache/config/configurations/default/flushPolicy/policies/flushAll/repositories, please create it with value category.
[INFO] [talledLocalContainer] 2014-08-13 13:07:29,488 ERROR info.magnolia.module.InstallContextImpl           : > Could not install or update personalization-integration module. Task 'Cache setup' failed. (PathNotFoundException: modules/cache/config/configurations)
Comment by Magnolia International [ 13/Aug/14 ]

Sheesh, I don't know how the checkstyle stuff escaped me. Pushed fixes. (They'll need to be squashed when merging to master)

Reported MGNLCACHE-70 for changes to be done on other modules (which will then be linked to modules' tickets if we decide to go down that route)

Where/how did you get the "NoSuchComponentException" and the NPE ?

Thanks for the review !

Comment by Roman Kovařík [ 14/Aug/14 ]

Where/how did you get the "NoSuchComponentException" and the NPE ?

I checked again upgrade of cache from 5.2.6 to 5.3 and no more NSCE/NPE so it was probably a miscofiguration from my side. Only this on startup:

2014-08-14 08:15:41,641 ERROR gnolia.jcr.node2bean.impl.Node2BeanTransformerImpl: Can't set property [persistence] to value [info.magnolia.module.cache.ehcache.EhCachePersistenceConfiguration@6186e175] in bean [info.magnolia.module.cache.ehcache.EhCacheConfiguration] for node /modules/cache/config/cacheFactory/caches/default due to java.lang.reflect.InvocationTargetException
2014-08-14 08:15:41,656 INFO  info.magnolia.module.ModuleManagerImpl            : Starting module cache
2014-08-14 08:15:41,656 WARN  net.sf.ehcache.config.ConfigurationFactory        : No configuration found. Configuring ehcache from ehcache-failsafe.xml  found in the classpath: jar:file:/Users/romankovarik/bundles/5.3.2/ee/magnolia-enterprise-5.3.2/apache-tomcat-7.0.47/webapps/magnoliaAuthor/WEB-INF/lib/ehcache-2.8.3.jar!/ehcache-failsafe.xml
Comment by Roman Kovařík [ 18/Aug/14 ]

Grégory Joseph: could you start with debug logs or put a break in n2b to see that that exception is ?

net.sf.ehcache.config.InvalidConfigurationException: Cannot use both <persistence ...> and diskPersistent in a single cache configuration.

So it's probably caused by http://jira.magnolia-cms.com/browse/MGNLCACHE-59?focusedCommentId=89765&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-89765

Comment by Magnolia International [ 19/Aug/14 ]

Pushed fixes addressing your points; second round of review ?

Comment by Roman Kovařík [ 20/Aug/14 ]

Could we solve also the latest subtask MGNLCACHE-70, so we can do the final review, QA etc.?

Generated at Sun Feb 11 23:51:45 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.