Remove deprecated "pattern" cache update event handling

Description

See https://sakaiproject.atlassian.net/browse/KNL-1162#icft=KNL-1162

This ticket is for removing the deprecated use of patterns in the caches. All caches which call:
Cache MemoryService.newCache(String cacheName, CacheRefresher refresher, String pattern)
OR
Cache MemoryService.newCache(String cacheName, String pattern)
will be switched over to:
Cache MemoryService.newCache(String cacheName)

Any cache entry expiration will need to be handled manually at that point.

PATTERN CACHE:
The caching pattern (which is optionally configured when a cache is created) was meant to be a way to automatically remove entries in a cache when a change event occurs which matches the start of the pattern. In practice, this means the ref from the Event is checked against the pattern and if the ref startsWith the same chars then the cache entry that has a key matching that Event ref will be removed from the cache.
This is probably better handled in each service using the cache (and in some cases it is also handled in the service). For now, I am marking the pattern as deprecated but keeping the functionality in place.

Pattern cache used in:
BaseAliasService.java
SiteCacheImpl.java
BaseUserDirectoryService.java
MemoryServiceTest.java
GetUsersByEidTest.java

Pattern caches:
org.sakaiproject.user.api.UserDirectoryService.callCache
org.sakaiproject.site.impl.SiteCacheImpl.cache
org.sakaiproject.alias.api.AliasService.callCache

Stats from a fairly high load server:
org.sakaiproject.user.api.UserDirectoryService.callCache: count:4375 hits:4685826 misses:12141 hit%:99
org.sakaiproject.site.impl.SiteCacheImpl.cache: count:9810 hits:8841581 misses:667179 hit%:92
org.sakaiproject.alias.api.AliasService.callCache: count:1 hits:2 misses:7 hit%:22

Looks like the alias cache is basically worthless. The other 2 are critical though.

NOTE: we added the alias callCache back in for 10. It will be disabled for anyone using the new caching system

Solution note:
Viable options are only to have the event based stuff work while non-distributed caches are used (on a cache by cache basis) and disabled when distributed caches are used. Luckily, this only affects 2 current caches as all other caches do not properly invalidate across a cluster (and some do not even properly invalidate locally).
To support existing behavior I am willing to make the user and security caches work like they did but that mechanism should be handled in the code where the cache is used and should disable itself when the cache is distributed. That means MemoryService needs to have an API that allows someone to know if a cache is distributed for the short term. In the longer term we would simply not support the Sakai event flavored cache expirations.

Institutions who want a distributed cache would need to setup a real one like memcached or hazelcast or terracotta. This is in line with other LMSs (e.g. Moodle) and the majority of the software industry (e.g. Drupal) in general.

Attachments

4
  • 24 Apr 2014, 11:34 AM
  • 23 Apr 2014, 04:40 PM
  • 23 Apr 2014, 04:08 PM
  • 23 Apr 2014, 06:32 AM

Activity

Show:

Hudson CI Server April 24, 2014 at 2:05 PM

Integrated in sakai-trunk-java-1.7 #213 (See http://builds.sakaiproject.org:8080/job/sakai-trunk-java-1.7/213/)
https://sakaiproject.atlassian.net/browse/KNL-1229#icft=KNL-1229 Reinstating alias cache but disabling it for new caching system
Will remove this cache in 11 (Revision 308573)
https://sakaiproject.atlassian.net/browse/KNL-1229#icft=KNL-1229 reversing the removal of the cache (Revision 308571)

Result = UNSTABLE

Aaron Zeckoski April 24, 2014 at 11:34 AM

Adding patch which doesn't completely remove the alias cache but instead just disables it when the new caching system is enabled

Aaron Zeckoski April 24, 2014 at 10:14 AM

opening to restore the alias cache and switch to work like the user one

Hudson CI Server April 23, 2014 at 11:23 PM

Integrated in sakai-trunk-java-1.7 #211 (See http://builds.sakaiproject.org:8080/job/sakai-trunk-java-1.7/211/)
https://sakaiproject.atlassian.net/browse/KNL-1229#icft=KNL-1229 Remove deprecated "pattern" cache update event handling
All use of pattern caches removed except the specialized use in SiteCacheImpl which will be handled in the 1225 ticket (Revision 308556)

Result = UNSTABLE

Hudson CI Server April 23, 2014 at 7:27 PM

Integrated in sakai-trunk-java-1.7 #210 (See http://builds.sakaiproject.org:8080/job/sakai-trunk-java-1.7/210/)
https://sakaiproject.atlassian.net/browse/KNL-1162#icft=KNL-1162 https://sakaiproject.atlassian.net/browse/KNL-1229#icft=KNL-1229 Added in support to detect when a cache is distributed
This is necessary to support legacy event based expiration and modern distributed caching at the same time (Revision 308550)

Result = UNSTABLE

Fixed

Details

Priority

Affects versions

Fix versions

Components

Assignee

Reporter

Labels

Created April 10, 2014 at 2:18 PM
Updated April 25, 2018 at 3:19 PM
Resolved April 24, 2014 at 11:35 AM

Flag notifications