revert part of caching mechanism

This commit is contained in:
Athou
2013-07-25 10:38:23 +02:00
parent 73f2871235
commit c618e22c52
11 changed files with 69 additions and 188 deletions

View File

@@ -80,31 +80,21 @@ public class FeedSubscriptionService {
feedSubscriptionDAO.saveOrUpdate(sub);
taskGiver.add(feed);
cache.invalidateUserSubscriptions(user);
cache.invalidateUserRootCategory(user);
return feed;
}
public boolean unsubscribe(User user, Long subId){
public boolean unsubscribe(User user, Long subId) {
FeedSubscription sub = feedSubscriptionDAO.findById(user, subId);
if (sub != null) {
feedSubscriptionDAO.delete(sub);
cache.invalidateUserSubscriptions(user);
cache.invalidateUserRootCategory(user);
return true;
} else {
return false;
}
}
public List<FeedSubscription> getSubscriptions(User user) {
List<FeedSubscription> list = cache.getUserSubscriptions(user);
if (list == null) {
log.debug("sub list miss for {}", Models.getId(user));
list = feedSubscriptionDAO.findAll(user);
cache.setUserSubscriptions(user, list);
}
return list;
}
public Long getUnreadCount(FeedSubscription sub) {
Long count = cache.getUnreadCount(sub);
if (count == null) {
@@ -117,7 +107,7 @@ public class FeedSubscriptionService {
public Map<Long, Long> getUnreadCount(User user) {
Map<Long, Long> map = Maps.newHashMap();
List<FeedSubscription> subs = getSubscriptions(user);
List<FeedSubscription> subs = feedSubscriptionDAO.findAll(user);
for (FeedSubscription sub : subs) {
map.put(sub.getId(), getUnreadCount(sub));
}