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

ch.mfrey.thymeleaf.extras.cache.TTLCacheValidityChecker Maven / Gradle / Ivy

Go to download

A dialect for Thymeleaf that allows you to do partial page caching. Some parts of our webpage will never change during the lifetime of the application or a usersession, but the part should still be dynamic in the beginning. Working with Thymeleaf 3.0.0+ (3.0.0.RELEASE and its dependencies included)

There is a newer version: 3.0.1
Show newest version
package ch.mfrey.thymeleaf.extras.cache;

import java.util.List;

import org.thymeleaf.cache.ICacheEntryValidityChecker;

class TTLCacheValidityChecker implements ICacheEntryValidityChecker> {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    private final int cacheTTLs;

    public TTLCacheValidityChecker(int cacheTTLs) {
        super();
        this.cacheTTLs = cacheTTLs;
    }

    public boolean checkIsValueStillValid(String key, List value, long entryCreationTimestamp) {
        final long currentTimeInMillis = System.currentTimeMillis();
        return (currentTimeInMillis < entryCreationTimestamp + this.cacheTTLs * 1000);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy