001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (https://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: https://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: https://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.configuration; 029 030import org.opencms.db.storage.CmsInMemoryStoredContentInfoCacheFactory; 031 032/** 033 * Configuration for the stored content info cache.<p> 034 */ 035public class CmsStoredContentInfoCacheConfiguration { 036 037 /** The default cache size. */ 038 public static final int DEFAULT_SIZE = 10000; 039 040 /** The default time to live in seconds. */ 041 public static final long DEFAULT_TTL = 300; 042 043 /** The factory class. */ 044 private String m_factoryClass = CmsInMemoryStoredContentInfoCacheFactory.class.getName(); 045 046 /** Indicates if the cache is enabled. */ 047 private boolean m_enabled = true; 048 049 /** The maximum number of cached entries. */ 050 private int m_size = DEFAULT_SIZE; 051 052 /** The time to live in seconds. */ 053 private long m_ttl = DEFAULT_TTL; 054 055 /** 056 * Returns the factory class name.<p> 057 * 058 * @return the factory class name 059 */ 060 public String getFactoryClass() { 061 062 return m_factoryClass; 063 } 064 065 /** 066 * Returns the cache size.<p> 067 * 068 * @return the cache size 069 */ 070 public int getSize() { 071 072 return m_size; 073 } 074 075 /** 076 * Returns the time to live in seconds.<p> 077 * 078 * @return the time to live in seconds 079 */ 080 public long getTtl() { 081 082 return m_ttl; 083 } 084 085 /** 086 * Initializes the configuration.<p> 087 * 088 * @param factoryClass the factory class 089 * @param enabled if the cache is enabled 090 * @param size the maximum number of cached entries 091 * @param ttl the time to live in seconds 092 */ 093 public void initialize(String factoryClass, String enabled, String size, String ttl) { 094 095 m_factoryClass = factoryClass; 096 m_enabled = Boolean.valueOf(enabled).booleanValue(); 097 m_size = Integer.parseInt(size); 098 m_ttl = Long.parseLong(ttl); 099 } 100 101 /** 102 * Returns if the cache is enabled.<p> 103 * 104 * @return <code>true</code> if the cache is enabled 105 */ 106 public boolean isEnabled() { 107 108 return m_enabled; 109 } 110 111 /** 112 * Sets the factory class name.<p> 113 * 114 * @param factoryClass the factory class name 115 */ 116 public void setFactoryClass(String factoryClass) { 117 118 m_factoryClass = factoryClass; 119 } 120}