1 package com.atlassian.user.impl.cache;
2
3 import com.atlassian.user.User;
4 import com.atlassian.user.util.GenericCacheWrapper;
5 import com.atlassian.cache.*;
6
7 import java.util.List;
8
9
10
11
12
13
14
15
16 public class GroupsForUserCache
17 {
18 private final CacheFactory cacheFactory;
19 private final String cacheName;
20
21 public GroupsForUserCache(CacheFactory cacheFactory, String cacheName)
22 {
23 this.cacheFactory = cacheFactory;
24 this.cacheName = cacheName;
25 }
26
27 private GenericCacheWrapper<String, List<String>> getCache()
28 {
29 return new GenericCacheWrapper<String, List<String>>( cacheFactory.getCache(cacheName));
30 }
31
32 public void put(User user, List<String> groupNames)
33 {
34 getCache().put(user.getName(), groupNames);
35 }
36
37 public List<String> get(User user)
38 {
39 return getCache().get(user.getName());
40 }
41
42
43
44
45
46
47
48
49
50
51 public void remove(User user)
52 {
53 getCache().remove(user.getName());
54 }
55
56
57
58
59
60
61 public void remove(List<String> usernames)
62 {
63 for (String username : usernames)
64 {
65 getCache().remove(username);
66 }
67 }
68 }