in plugin/src/main/groovy/grails/plugins/redis/RedisService.groovy [174:192]
def memoizeHash(String key, Map options = [:], Closure closure) {
def hash = withOptionalRedis { Jedis redis ->
if (redis) return redis.hgetAll(key)
}
if (!hash) {
log.debug('cache miss: {}', key)
hash = closure()
if (hash) withOptionalRedis { Jedis redis ->
if (redis) {
redis.hmset(key, hash)
if (options?.expire) redis.expire(key, options.expire)
}
}
} else {
log.debug('cache hit : {} = {}', key, hash)
}
hash
}