source: autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/filter/FilterStatisticCache.java @ 1030

Last change on this file since 1030 was 1030, checked in by adeicke, 11 years ago

Initial commit.

  • Property svn:mime-type set to text/plain
File size: 1.2 KB
Line 
1package de.ugoe.cs.autoquest.usability.tasktree.filter;
2
3import java.util.concurrent.TimeUnit;
4
5import com.google.common.base.Optional;
6import com.google.common.cache.Cache;
7import com.google.common.cache.CacheBuilder;
8
9public class FilterStatisticCache {
10
11    private static final FilterStatisticCache instance = new FilterStatisticCache();
12   
13    @SuppressWarnings("rawtypes")
14    private Cache<TaskTreeNodeFilter, FilterStatistic> cache;
15   
16    private FilterStatisticCache() {
17        this.cache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).build();
18    }
19   
20    public static FilterStatisticCache instance() {
21        return instance;
22    }
23   
24    @SuppressWarnings("rawtypes")
25    public void addFilterStatistic(TaskTreeNodeFilter nodeFilter, FilterStatistic filterStatistic) {
26        this.cache.put(nodeFilter, filterStatistic);
27    }
28   
29    @SuppressWarnings("rawtypes")
30    public Optional<FilterStatistic> getFilterStatistic(TaskTreeNodeFilter nodeFilter) {
31        return Optional.fromNullable(this.cache.getIfPresent(nodeFilter));
32    }
33   
34    public void clear() {
35        this.cache.invalidateAll();
36    }
37   
38}
Note: See TracBrowser for help on using the repository browser.