1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.cache.config

File LRUCacheConfiguration.java

 

Coverage histogram

../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
14
5
1
101
36
5
0.36
2.8
5
1

Classes

Class Line # Actions
LRUCacheConfiguration 31 14 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 177 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.cache.config;
21   
22    import org.xwiki.cache.eviction.EntryEvictionConfiguration;
23    import org.xwiki.cache.eviction.LRUEvictionConfiguration;
24   
25    /**
26    * Cache configuration using LRU eviction method.
27    *
28    * @version $Id: 380630285812aa90f1feb9979a3702876832a872 $
29    * @since 4.3M1
30    */
 
31    public class LRUCacheConfiguration extends CacheConfiguration
32    {
33    /**
34    * Unique id for serialization.
35    */
36    private static final long serialVersionUID = 1L;
37   
38    /**
39    * Creates new LRUCacheConfiguration instance with empty (null) configurationId, default size of 100 and time to
40    * live 0.
41    */
 
42  1 toggle public LRUCacheConfiguration()
43    {
44  1 this(null);
45    }
46   
47    /**
48    * Creates new LRUCacheConfiguration instance with given configurationId, default max size of 100 and time to live
49    * 0.
50    *
51    * @param configurationId configuration identifier
52    */
 
53  1 toggle public LRUCacheConfiguration(String configurationId)
54    {
55  1 super(configurationId);
56   
57  1 LRUEvictionConfiguration lru = new LRUEvictionConfiguration();
58  1 put(EntryEvictionConfiguration.CONFIGURATIONID, lru);
59    }
60   
61    /**
62    * Creates new LRUCacheConfiguration instance with given configurationId and max size, and default time to live 0.
63    *
64    * @param configurationId configuration identifier
65    * @param maxSize maximum cache capacity
66    */
 
67  424 toggle public LRUCacheConfiguration(String configurationId, int maxSize)
68    {
69  424 super(configurationId);
70   
71  424 LRUEvictionConfiguration lru = new LRUEvictionConfiguration();
72  424 lru.setMaxEntries(maxSize);
73  424 put(EntryEvictionConfiguration.CONFIGURATIONID, lru);
74    }
75   
76    /**
77    * Creates new LRUCacheConfiguration instance with given configurationId, max size and time to live.
78    *
79    * @param configurationId configuration identifier
80    * @param maxSize maximum cache capacity
81    * @param maxIdle for how long cache entry will be valid (in seconds) since the last time it was used
82    */
 
83  320 toggle public LRUCacheConfiguration(String configurationId, int maxSize, int maxIdle)
84    {
85  320 super(configurationId);
86   
87  320 LRUEvictionConfiguration lru = new LRUEvictionConfiguration();
88  320 lru.setMaxEntries(maxSize);
89  320 lru.setMaxIdle(maxIdle);
90  320 put(EntryEvictionConfiguration.CONFIGURATIONID, lru);
91    }
92   
93    /**
94    * @return the eviction configuration as a {@link LRUEvictionConfiguration} instance
95    * @since 7.4M2
96    */
 
97  5 toggle public LRUEvictionConfiguration getLRUEvictionConfiguration()
98    {
99  5 return (LRUEvictionConfiguration) get(EntryEvictionConfiguration.CONFIGURATIONID);
100    }
101    }