1 package com.atlassian.user.impl.cache;
2
3 import com.atlassian.user.repository.RepositoryIdentifier;
4 import com.atlassian.user.Entity;
5 import com.atlassian.cache.CacheFactory;
6
7
8
9
10
11
12
13
14
15
16
17
18 public class EntityRepositoryCache
19 {
20 private final CacheFactory cacheFactory;
21 private final String cacheName;
22
23 public EntityRepositoryCache(CacheFactory cacheFactory, String cacheName)
24 {
25 this.cacheFactory = cacheFactory;
26 this.cacheName = cacheName;
27 }
28
29 private com.atlassian.cache.Cache getCache()
30 {
31 return cacheFactory.getCache(cacheName);
32 }
33
34 public void put(Entity entity, RepositoryIdentifier repository)
35 {
36 getCache().put(entity.getName(), repository);
37 }
38
39
40
41
42
43 public RepositoryIdentifier get(Entity entity)
44 {
45 return (RepositoryIdentifier) getCache().get(entity.getName());
46 }
47
48 public void remove(Entity entity)
49 {
50 getCache().remove(entity.getName());
51 }
52 }