001/*
002 *  Copyright 2013 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016
017package org.ametys.web.cache.monitoring.process.statistics;
018
019import org.apache.ibatis.session.SqlSession;
020
021/**
022 * A ResourceCacheStats is an object that holds cache statistics coming from the
023 * monitoring database or to be inserted/updated in the monitoring database.
024 */
025public interface ResourceStatistics
026{
027    /**
028     * Creates and configure a statement with a find query.
029     * @param sqlSession The sql session
030     * @return A non null ready to execute prepared statement
031     */
032    public boolean statExists(SqlSession sqlSession);
033    
034    /**
035     * Creates and configure a statement with an insert query.
036     * @param sqlSession The sql session
037     */
038    public void createStat(SqlSession sqlSession);
039    
040    /**
041     * Creates and configure a statement with an update query.
042     * @param sqlSession The sql session
043     */
044    public void updateStat(SqlSession sqlSession);
045    
046    /**
047     * Returns the number of hits
048     * @return int the hits
049     */
050    public int getHits();
051}