class IncrementCounterInCacheAdvice extends CounterInCacheBase {

    @AfterReturning("incrementSingleCounter()")
    public void incrementSingle(final JoinPoint jp) throws Throwable {
        if (isDisabled()) {
            getLogger().info("Cache disabled");
            return;
        }

        // This is injected caching. If anything goes wrong in the caching, LOG
        // the crap outta it, but do not let it surface up past the AOP injection itself.
        // It will be invoked only if underlying method completes successfully.
        String cacheKey = null;
        IncrementCounterInCache annotation;
        try {
            Method methodToCache = getCacheBase().getMethodToCache(jp, IncrementCounterInCache.class);
            annotation = methodToCache.getAnnotation(IncrementCounterInCache.class);
            AnnotationData data = AnnotationDataBuilder.buildAnnotationData(annotation, IncrementCounterInCache.class, methodToCache);
            cacheKey = getCacheBase().getCacheKeyBuilder().getCacheKey(data, jp.getArgs(), methodToCache.toString());
            getCacheBase().getCache(data).incr(cacheKey, 1, 1);
        } catch (Exception ex) {
            warn(ex, "Incrementing counter [%s] via %s aborted due to an error.", cacheKey, jp.toShortString());
        }
    }

}