001package io.ebean.cache; 002 003import java.util.Set; 004 005/** 006 * For query cache entries we additionally hold the dependent tables and timestamp for the query result. 007 * <p> 008 * We use the dependent tables and timestamp to validate that tables the query joins to have not been 009 * modified since the query cache entry was cached. If any dependent tables have since been modified 010 * the query cache entry is treated as invalid. 011 * </p> 012 */ 013public class QueryCacheEntry { 014 015 private final Object value; 016 private final Set<String> dependentTables; 017 private final long timestamp; 018 019 /** 020 * Create with dependent tables and timestamp. 021 * 022 * @param value The query result being cached 023 * @param dependentTables The extra tables the query is dependent on (joins to) 024 * @param timestamp The timestamp that the query uses to check for modifications 025 */ 026 public QueryCacheEntry(Object value, Set<String> dependentTables, long timestamp) { 027 this.value = value; 028 this.dependentTables = dependentTables; 029 this.timestamp = timestamp; 030 } 031 032 /** 033 * Return the actual query result. 034 */ 035 public Object getValue() { 036 return value; 037 } 038 039 /** 040 * Return the tables the query result is dependent on. 041 */ 042 public Set<String> getDependentTables() { 043 return dependentTables; 044 } 045 046 /** 047 * Return the timestamp used to check for modifications on the dependent tables. 048 */ 049 public long getTimestamp() { 050 return timestamp; 051 } 052}