
|
If you were logged in you would be able to see more operations.
|
|
|
OSCache
Created: 03/Dec/03 06:17 AM
Updated: 08/Mar/07 12:29 AM
|
|
| Component/s: |
Filters
|
| Affects Version/s: |
2.0.2
|
| Fix Version/s: |
2.2 RC
|
|
|
Environment:
|
Any Java Platform
|
|
Issue Links:
|
Duplicate
|
|
|
|
This issue is duplicated by:
|
|
CACHE-171
CacheFilter easier sub-classing via k...
|
|
|
|
Required
|
|
|
|
This issue is required by:
|
|
CACHE-84
Include user locale in key generation
|
|
|
|
|
|
|
At the moment using the CacheFilter the key generation is done transparently in the ServletCacheAdministrator class.
If i wanted to have my own custom key generation (e.g. add a suffix like a request attribute), i would have to implement my own custom cache filter. The problem with this is that its not future proof, because for any new versions of oscache i would have to re-check my custom cache filter and possibly re-implement. Also its not possible currently to extend ServletCacheAdministrator (because its got a private constructor), so that i could override the generateKey method.
What would be nice if the generateKey method in ServletCacheAdministrator would accept a request attribute that allowed the cache key to be overridden completely (i.e. generateKey(CacheEntryKey key, ...)) and that the cache filter had a method where this request attribute is built (see below), therefore if i wanted to change the process of creating the cache entry key, i would simply extend CacheFilter and override this method.
// Example change to cachefilter
public class CacheFilter implements Filter {
...
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
...
CacheEntryKey cacheEntryKey = generateEntryKey(httpRequest);
key = admin.generateEntryKey(cacheEntryKey , httpRequest, cacheScope);
...
}
public CacheEntryKey generateEntryKey(
ServletRequest request) {
}
|
|
Description
|
At the moment using the CacheFilter the key generation is done transparently in the ServletCacheAdministrator class.
If i wanted to have my own custom key generation (e.g. add a suffix like a request attribute), i would have to implement my own custom cache filter. The problem with this is that its not future proof, because for any new versions of oscache i would have to re-check my custom cache filter and possibly re-implement. Also its not possible currently to extend ServletCacheAdministrator (because its got a private constructor), so that i could override the generateKey method.
What would be nice if the generateKey method in ServletCacheAdministrator would accept a request attribute that allowed the cache key to be overridden completely (i.e. generateKey(CacheEntryKey key, ...)) and that the cache filter had a method where this request attribute is built (see below), therefore if i wanted to change the process of creating the cache entry key, i would simply extend CacheFilter and override this method.
// Example change to cachefilter
public class CacheFilter implements Filter {
...
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
...
CacheEntryKey cacheEntryKey = generateEntryKey(httpRequest);
key = admin.generateEntryKey(cacheEntryKey , httpRequest, cacheScope);
...
}
public CacheEntryKey generateEntryKey(
ServletRequest request) {
} |
Show » |
|
String key = admin.generateEntryKey(null, httpRequest, cacheScope);
with
String key = generateEntryKey(httpRequest);
and add the method
/**
* Creates the cache key for the CacheFilter.
*
* @param httpRequest
* @return the cache key
*/
public String calculateKey(HttpServletRequest httpRequest) {
return admin.generateEntryKey(null, httpRequest, cacheScope);
}