private synchronized Collection<Rule> filterAndSetRulesInLastTwoHoursFromCache() {
        if (lastTime < System.currentTimeMillis() - cachedRulesTimeout) {
            Collection<Rule> rules = (Collection<Rule>) getCached(getCachedRulesKey());
            boolean update = false;
            if (rules != null) {
                for (Rule rule : rules) {
                    if (rule.getTimestamp() < System.currentTimeMillis() - refreshTimeout) {
                        update = true;
                        break;
                    }
                }
            }

            if (update) {
                try {
                    CASMutation<Collection<Rule>> mutation = new CASMutation<Collection<Rule>>() {
                        public Collection<Rule> getNewValue(Collection<Rule> current) {

                            ArrayList<Rule> currentRules = new ArrayList<Rule>(current);
                            for (Iterator<Rule> iterator = currentRules.iterator(); iterator.hasNext();) {
                                Rule rule = iterator.next();
                                if (rule.getTimestamp() < System.currentTimeMillis() - refreshTimeout) {
                                    iterator.remove();
                                }
                            }
                            return currentRules;
                        }
                    };
                    casmp.get().cas(getCachedRulesKey(), null, 0, mutation);
                } catch (Exception e) {
                    ApplicationHelper.ignore(e);
                }
            }
            if (rules == null) {
                rules = Collections.emptyList();
            }
            cachedRules = rules;
            lastTime = System.currentTimeMillis();
        }
        return cachedRules;
    }