org.rythmengine.spring.web.CacheFor Maven / Gradle / Ivy
package org.rythmengine.spring.web;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Use this annotation on a controller handling method to indicate the
* view returned by the handling method will be cached
*
* If a time is not specified, the results will be cached for 1 hour by default.
*
*
Example: @CacheFor("1h")
*
*
If rythm.cache.prodOnly
configuration is true,
* then cache will not effect on dev mode
*
*
Be sure not to use {@code CacheFor} on certain static page, such as
* an input form page. The reason is although form looks like the same
* every time to end user, however there might have content changes, say
* the csrf token, or at least do not use a very long expiration time
* when you really want to cache the form input page
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CacheFor {
/**
* Cache time. Support the following type:
*
* - 1s: one second
* - 2mn: two minutes
* - 3h: three hours
* - foreaver: never expire
*
*
* @return cache expiration time
*/
String value() default "1h";
/**
* Define the cache key. Leave it empty if you want system to generate key
* from request automatically
*
* @return the session key provider class
*/
Class extends CacheKeyProvider> key() default CacheKeyProvider.Default.class;
/**
* Whether use session id to generate the cache key, meaning if the cached copy is
* for session specific or not
* default: false
*
* @return true if it is session sensitive
*/
boolean sessionSensitive() default false;
/**
* Whether use current locale to generate the cache key.
* Default: false
*
* @return true if it is language sensitive
*/
boolean langSensitive() default false;
/**
* Whether the cache key is sensitive to request.secure. When this parameter
* is set to true
, then the request coming from http and https channel
* will result in different cached copy
*
* default: false
*
* @return true if key is http scheme sensitive
*/
boolean schemeSensitive() default false;
/**
* Indicate whether cache post request. Useful for certain case,
* e.g. facebook always post to tab page in iframe
* default: false
*
* @return true if cache post request also
*/
boolean cachePost() default false;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy