Cache Service¶
Topics
Cache¶
Cache is a function to allow the objects to be saved utilizing the memory on the application server.Performance of application can be improved by putting the result data of database access or file access to the cache.
Specifications¶
EHCache is used as standard as Cache implementation.With regard to EHCache, please see http://ehcache.org.Objects that are registered in the Cache would be discarded, if they exceed the number of elements or the upper limit of size specified in the setting file.Objects whose validity period has expired would also be discarded.In case Cache is used, setting of Cache needs to be made by placing the xml file of arbitrary name under the <CONTEXT_PATH>/WEB-INF/conf/im-ehcache-config/ folder.Example of the setting file is shown below.<?xml version="1.0" encoding="UTF-8"?> <im-ehcache-config xmlns="http://www.intra-mart.jp/cache/ehcache/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.intra-mart.jp/cache/ehcache/config im-ehcache-config.xsd "> <cache name="myCache" enable="true" max-bytes-memory="10m" max-elements-on-memory="100" overflow-to-disk="true" max-bytes-disk="50m" max-elements-on-disk="500" time-to-idle-seconds="600" time-to-live-seconds="3600" /> </im-ehcache-config>Warning
Set character code to UTF-8 and save it.Details about each setting are as follows :
Attribute Name Description name Cache name is set. enable true or false is specified. If false is specified, subject Cache is disabled. max-btyes-memory Maximum size for storing objects to the memory is specified. Notation such as 1k, 10M, or 50G is allowed. max-elements-on-memory Maximum number of objects to be cached on the memory is specified. overflow-to-disk Set if the data should be moved to the disk when the upper limit of cache region on memory is exceeded. max-bytes-disk Maximum size for storing objects to the disk is specified. Notation such as 1k, 10M, or 50G is allowed. max-elements-on-disk Maximum number of objects to be cached on the disk is specified. time-to-idle-seconds Idle time (seconds) is specified. If the object is not accessed for the specified time period, it will be discarded. time-to-live-seconds Survival time (seconds) is specified. If the object is alive beyond the specified time period, it will be discarded. Note
In case [max-bytes-memory] and [max-bytes-disk] attributes are set, size of the object is computed when the object is registered to Cache.If the object to be registered has a large volume of references to other objects, computing process would take too much time and could cause perfromance degradation.If the object to be registered has 1000 or more references, the message below will be generated to the log.The configured limit of 1,000 object references was reached while attempting to calculate the size of the object graph. Severe performance degradation could occur if the sizing operation continues. This can be avoided by setting the CacheManger or Cache <sizeOfPolicy> elements maxDepthExceededBehavior to "abort" or adding stop points with @IgnoreSizeOf annotations. If performance degradation is NOT an issue at the configured limit, raise the limit value using the CacheManager or Cache <sizeOfPolicy> elements maxDepth attribute. For more information, see the Ehcache configuration documentation.In case this log is generated, you should change the object configuration stored into cache, or you should plan to use [max-elements-on-memory] or [max-elements-on-disk] instead of [max-bytes-memory] or [max-bytes-disk].