Cache functions differ with default Object Cache

Description

I found the reason for the incompatibility. Cache regions created in the admin server context is always shared among all applications while cache regions in the admin web context is exclusive to the corresponding application.

Although the way it works is consequent due to the major differences in caching between ACF and Lucee, it will still break applications moving from ACF to Lucee. And to be honest, it's quite a hassle if you have to create the default cache for every single application.

The cache functions cacheGet and cachePut (and the corresponding cfcache tags) work differently in Lucee and ACF when omitting the region (cacheName). Omitting the region will use the default Object Cache according to the documentation.

In Lucee, the default Object Cache is a global (instance wide) container for all objects of any application in the same instance. Thus the keys are shared between multiple applications. This behavior holds true for both caching types: EHCache and RamCache.

In ACF, the default Object Cache is a local (application bound) container for objects placed in the context of the application only. Thus the keys are not shared between multiple applications.

The following example demonstrates the difference:

/appA/Application.cfc

component { this.name = 'AppA'; }

/appB/Application.cfc

component { this.name = 'AppB'; }

/appA/index.cfm and /appB/index.cfm

<cfscript> cachedVar = cacheGet("test"); if (isNull(cachedVar)) { cachedVar = APPLICATION.ApplicationName; cachePut("test", cachedVar); } writeOutput(cachedVar); </cfscript>

Output in Lucee (starting with a request of /appA/index.cfm):

/appA/index.cfm >> AppA

/appB/index.cfm >> AppA

Output in ACF (starting with a request of /appA/index.cfm):

/appA/index.cfm >> AppA

/appB/index.cfm >> AppB

The function cacheGetAllIDs() follows the same rules. In Lucee, it will return the keys of all applications. In ACF, it will return the keys of the current application only.

Activity

Show:

Pothys - MitrahSoft 28 November 2016 at 07:16

I've added test case for this ticket. In lucee, the default Object Cache is a global shared their keys having the same instance. Thus the keys are shared between multiple applications.It is container for all objects of any application in the same instance.

In ACF,the default Object Cache is a local (application bound) only. It is container for objects placed in the context of the application only. Thus the keys are not shared between multiple applications.

Pull Request: https://github.com/lucee/Lucee/pull/111

Former user 22 June 2016 at 21:51

I am converting an ACF 9 app to Lucee 4.5.2 and am having the exact issue described in this ticket.

ACF makes is super simple to create a cache, whereas Lucee is throwing an error for not following its particular set of rules, and there's no documentation for it, that I have found. So there should be a setting in Lucee to mimic ACF caching behavior so I can get my application converted over, and not have to dick around with figuring this out. I'm not the only one, just one of the few to comment.

I can understand the awesomeness of choosing which cache to make default. But if I want to mimic ACF caching behavior, Lucee should create a default object cache for me; call it default. Also, there should be one auto-created for each app locally, like ACF does.

Thanks.

Alexander Kwaschny 4 November 2015 at 10:37
Edited

Found the reason to the problem and updated the ticket accordingly. It's more of a feature request now.

Details

Assignee

Reporter

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Priority

Created 27 September 2015 at 23:02
Updated 19 December 2016 at 14:29

Flag notifications