All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.rythmengine.spring.web.CacheFor Maven / Gradle / Ivy

Go to download

Enable Spring Application Developer to use Rythm Template Engine to render views

The newest version!
package org.rythmengine.spring.web;

/*-
 * #%L
 * Spring Rythm Plugin
 * %%
 * Copyright (C) 2017 - 2018 OSGL (Open Source General Library)
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

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 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