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

org.hibernate.cache.redis.client.RedisTimestamper Maven / Gradle / Ivy

The newest version!
package org.hibernate.cache.redis.client;

import org.hibernate.cache.redis.util.CacheTimestamper;

import java.util.Collections;
import java.util.List;

/**
 * @author Johno Crawford ([email protected])
 */
public class RedisTimestamper implements CacheTimestamper {

    private final RedisClient redisClient;
    private final List timestampCacheKey;

    public RedisTimestamper(RedisClient redisClient, String cacheKey) {
        this.redisClient = redisClient;
        this.timestampCacheKey = Collections.singletonList(cacheKey + "timestamp");
    }

    @Override
    public long next() {
        return redisClient.nextTimestamp(timestampCacheKey);
    }
}