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.runtime.cache.tag.query;
020
021import java.io.Serializable;
022
023import lucee.commons.digest.HashUtil;
024import lucee.runtime.cache.tag.CacheItem;
025import lucee.runtime.cache.tag.udf.UDFArgConverter;
026import lucee.runtime.type.Struct;
027
028public class StoredProcCacheItem implements CacheItem, Serializable {
029
030        private static final long serialVersionUID = 7327671003736543783L;
031
032
033        private Struct sct;
034
035
036        private String procedure;
037
038
039        private long executionTime;
040
041
042        public StoredProcCacheItem(Struct sct, String procedure, long executionTime) {
043                this.sct=sct;
044                this.procedure=procedure;
045                this.executionTime=executionTime;
046        }
047
048        @Override
049        public String getHashFromValue() {
050                return Long.toString(HashUtil.create64BitHash(UDFArgConverter.serialize(sct)));
051        }
052        
053        @Override
054        public String getName() {
055                return procedure;
056        }
057
058        @Override
059        public long getPayload() {
060                return sct.size();
061        }
062        
063        @Override
064        public String getMeta() {
065                return "";
066        }
067        
068        @Override
069        public long getExecutionTime() {
070                return executionTime;
071        }
072
073        public Struct getStruct() {
074                return sct;
075        }
076
077}