001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.commons.io.cache;
020
021import java.util.Date;
022
023import lucee.runtime.type.Struct;
024
025
026/**
027 * interface for a entry inside the cache, this interface is read-only
028 */
029public interface CacheEntry {
030        
031        /**
032         * when was the entry accessed last time.
033         * this information is optional and depends on the implementation,
034         * when information is not available -1 is returned
035         * @return time in milliseconds since 1/1/1970 GMT
036         */
037        public Date lastHit();
038        
039        /**
040         * when was the entry last time modified.
041         * this information is optional and depends on the implementation,
042         * when information is not available -1 is returned
043         * @return time offset in milliseconds since 1/1/1970 GMT
044         */
045        public Date lastModified();
046        
047        /**
048         * when was the entry created.
049         * this information is optional and depends on the implementation,
050         * when information is not available -1 is returned
051         * @return time offset in milliseconds since 1/1/1970 GMT
052         */
053        public Date created();
054        
055        /**
056         * how many time was the entry accessed?
057         * this information is optional and depends on the implementation,
058         * when information is not available -1 is returned
059         * @return access count
060         */
061        public int hitCount();
062        
063        
064        /**
065         * @return the key associated with this entry
066         */
067        public String getKey();
068        
069        /**
070         * @return the value associated with this entry
071         */
072        public Object getValue();
073        
074        /**
075         * the size of the object
076         * @return size of the object
077         */
078        public long size();
079        
080        /**
081         * define time until the entry is valid
082         * @return time offset in milliseconds since 1/1/1970 GMT or Long.MIN_VALUE if value is not defined
083         */
084        public long liveTimeSpan();
085        
086        /**
087         * time in milliseconds after which the object is flushed from the cache if it is not accessed during that time.
088         * @return time milliseconds  since 1/1/1970 GMT or Long.MIN_VALUE if value is not defined
089         */
090        public long idleTimeSpan();
091
092        /**
093         * get all information data available for this entry
094         */
095        public Struct getCustomInfo();
096}