ehcache-shiro-default.xml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <!--
  2. ~ Licensed to the Apache Software Foundation (ASF) under one
  3. ~ or more contributor license agreements. See the NOTICE file
  4. ~ distributed with this work for additional information
  5. ~ regarding copyright ownership. The ASF licenses this file
  6. ~ to you under the Apache License, Version 2.0 (the
  7. ~ "License"); you may not use this file except in compliance
  8. ~ with the License. You may obtain a copy of the License at
  9. ~
  10. ~ http://www.apache.org/licenses/LICENSE-2.0
  11. ~
  12. ~ Unless required by applicable law or agreed to in writing,
  13. ~ software distributed under the License is distributed on an
  14. ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. ~ KIND, either express or implied. See the License for the
  16. ~ specific language governing permissions and limitations
  17. ~ under the License.
  18. -->
  19. <ehcache>
  20. <!-- Sets the path to the directory where cache .data files are created.
  21. If the path is a Java System Property it is replaced by
  22. its value in the running VM. The following properties are translated:
  23. user.home - User's home directory
  24. user.dir - User's current working directory
  25. java.io.tmpdir - Default temp file path
  26. -->
  27. <diskStore path="java.io.tmpdir/shiro-ehcache"/>
  28. <!--Default Cache configuration. These will applied to caches programmatically created through
  29. the CacheManager.
  30. The following attributes are required:
  31. maxElementsInMemory - Sets the maximum number of objects that will be created in memory
  32. eternal - Sets whether elements are eternal. If eternal, timeouts are ignored and the
  33. element is never expired.
  34. overflowToDisk - Sets whether elements can overflow to disk when the in-memory cache
  35. has reached the maxInMemory limit.
  36. The following attributes are optional:
  37. timeToIdleSeconds - Sets the time to idle for an element before it expires.
  38. i.e. The maximum amount of time between accesses before an element expires
  39. Is only used if the element is not eternal.
  40. Optional attribute. A value of 0 means that an Element can idle for infinity.
  41. The default value is 0.
  42. timeToLiveSeconds - Sets the time to live for an element before it expires.
  43. i.e. The maximum time between creation time and when an element expires.
  44. Is only used if the element is not eternal.
  45. Optional attribute. A value of 0 means that and Element can live for infinity.
  46. The default value is 0.
  47. diskPersistent - Whether the disk store persists between restarts of the Virtual Machine.
  48. The default value is false.
  49. diskExpiryThreadIntervalSeconds- The number of seconds between runs of the disk expiry thread. The default value
  50. is 120 seconds.
  51. memoryStoreEvictionPolicy - Policy would be enforced upon reaching the maxElementsInMemory limit. Default
  52. policy is Least Recently Used (specified as LRU). Other policies available -
  53. First In First Out (specified as FIFO) and Less Frequently Used
  54. (specified as LFU)
  55. -->
  56. <defaultCache
  57. maxElementsInMemory="10000"
  58. eternal="false"
  59. timeToIdleSeconds="120"
  60. timeToLiveSeconds="120"
  61. overflowToDisk="false"
  62. diskPersistent="false"
  63. diskExpiryThreadIntervalSeconds="120"
  64. />
  65. <!-- We want eternal="true" and no timeToIdle or timeToLive settings because Shiro manages session
  66. expirations explicitly. If we set it to false and then set corresponding timeToIdle and timeToLive properties,
  67. ehcache would evict sessions without Shiro's knowledge, which would cause many problems
  68. (e.g. "My Shiro session timeout is 30 minutes - why isn't a session available after 2 minutes?"
  69. Answer - ehcache expired it due to the timeToIdle property set to 120 seconds.)
  70. diskPersistent=true since we want an enterprise session management feature - ability to use sessions after
  71. even after a JVM restart. -->
  72. <cache name="shiro-activeSessionCache"
  73. maxElementsInMemory="10000"
  74. overflowToDisk="true"
  75. eternal="true"
  76. timeToLiveSeconds="0"
  77. timeToIdleSeconds="0"
  78. diskPersistent="true"
  79. diskExpiryThreadIntervalSeconds="600"/>
  80. <cache name="org.apache.shiro.realm.text.PropertiesRealm-0-accounts"
  81. maxElementsInMemory="1000"
  82. eternal="true"
  83. overflowToDisk="true"/>
  84. </ehcache>