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 017 private final Set<String> dependentTables; 018 019 private final long timestamp; 020 021 /** 022 * Create with dependent tables and timestamp. 023 * 024 * @param value The query result being cached 025 * @param dependentTables The extra tables the query is dependent on (joins to) 026 * @param timestamp The timestamp that the query uses to check for modifications 027 */ 028 public QueryCacheEntry(Object value, Set<String> dependentTables, long timestamp) { 029 this.value = value; 030 this.dependentTables = dependentTables; 031 this.timestamp = timestamp; 032 } 033 034 /** 035 * Return the actual query result. 036 */ 037 public Object getValue() { 038 return value; 039 } 040 041 /** 042 * Return the tables the query result is dependent on. 043 */ 044 public Set<String> getDependentTables() { 045 return dependentTables; 046 } 047 048 /** 049 * Return the timestamp used to check for modifications on the dependent tables. 050 */ 051 public long getTimestamp() { 052 return timestamp; 053 } 054}