ehcache-shiro.xml 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <ehcache>
  3. <diskStore path="java.io.tmpdir/shiro-ehcache"/>
  4. <!--
  5. name:缓存名称。
  6. maxElementsInMemory:缓存最大数目
  7. maxElementsOnDisk:硬盘最大缓存个数。
  8. eternal:对象是否永久有效,一但设置了,timeout将不起作用。
  9. overflowToDisk:是否保存到磁盘,当系统当机时
  10. timeToIdleSeconds:设置对象在失效前的允许闲置时间(单位:秒)。仅当eternal=false对象不是永久有效时使用,可选属性,默认值是0,也就是可闲置时间无穷大。
  11. timeToLiveSeconds:设置对象在失效前允许存活时间(单位:秒)。最大时间介于创建时间和失效时间之间。仅当eternal=false对象不是永久有效时使用,默认是0.,也就是对象存活时间无穷大。
  12. diskPersistent:是否缓存虚拟机重启期数据 Whether the disk store persists between restarts of the Virtual Machine. The default value is false.
  13. diskSpoolBufferSizeMB:这个参数设置DiskStore(磁盘缓存)的缓存区大小。默认是30MB。每个Cache都应该有自己的一个缓冲区。
  14. diskExpiryThreadIntervalSeconds:磁盘失效线程运行时间间隔,默认是120秒。
  15. memoryStoreEvictionPolicy:当达到maxElementsInMemory限制时,Ehcache将会根据指定的策略去清理内存。默认策略是LRU(最近最少使用)。你可以设置为FIFO(先进先出)或是LFU(较少使用)。
  16. clearOnFlush:内存数量最大时是否清除。
  17. memoryStoreEvictionPolicy:
  18. Ehcache的三种清空策略;
  19. FIFO,first in first out,这个是大家最熟的,先进先出。
  20. LFU, Less Frequently Used,就是上面例子中使用的策略,直白一点就是讲一直以来最少被使用的。如上面所讲,缓存的元素有一个hit属性,hit值最小的将会被清出缓存。
  21. LRU,Least Recently Used,最近最少使用的,缓存的元素有一个时间戳,当缓存容量满了,而又需要腾出地方来缓存新的元素的时候,那么现有缓存元素中时间戳离当前时间最远的元素将被清出缓存。
  22. -->
  23. <defaultCache
  24. maxElementsInMemory="10000"
  25. eternal="false"
  26. timeToIdleSeconds="120"
  27. timeToLiveSeconds="120"
  28. overflowToDisk="false"
  29. diskPersistent="false"
  30. diskExpiryThreadIntervalSeconds="120"
  31. />
  32. <!--认证缓存的名称-->
  33. <cache name="goodAuthenticationCache"
  34. maxElementsInMemory="10000"
  35. overflowToDisk="true"
  36. eternal="true"
  37. timeToLiveSeconds="0"
  38. timeToIdleSeconds="0"
  39. diskPersistent="true"
  40. diskExpiryThreadIntervalSeconds="600"/>
  41. <!--授权缓存的名称-->
  42. <cache name="goodAuthorizationCache"
  43. maxElementsInMemory="10000"
  44. overflowToDisk="true"
  45. eternal="true"
  46. timeToLiveSeconds="0"
  47. timeToIdleSeconds="0"
  48. diskPersistent="true"
  49. diskExpiryThreadIntervalSeconds="600"/>
  50. <!--活动session缓存-->
  51. <cache name="shiro-activeSessionCache"
  52. maxElementsInMemory="10000"
  53. overflowToDisk="true"
  54. eternal="true"
  55. timeToLiveSeconds="0"
  56. timeToIdleSeconds="0"
  57. diskPersistent="true"
  58. diskExpiryThreadIntervalSeconds="600"/>
  59. </ehcache>