def memoizeList()

in plugin/src/main/groovy/grails/plugins/redis/RedisService.groovy [384:404]


    def memoizeList(String key, Map options = [:], Closure closure) {
        List list = withOptionalRedis { Jedis redis ->
            if (redis) return redis.lrange(key, 0, -1)
        }

        if (!list) {
            log.debug('cache miss: {}', key)
            list = closure()
            if (list) withOptionalPipeline { pipeline ->
                if (pipeline) {
                    for (obj in list) {
                        pipeline.rpush(key, obj)
                    }
                    if (options?.expire) pipeline.expire(key, options.expire)
                }
            }
        } else {
            log.debug('cache hit: {}', key)
        }
        list
    }