in plugin/src/main/groovy/grails/plugins/redis/RedisService.groovy [410:430]
def memoizeSet(String key, Map options = [:], Closure closure) {
def set = withOptionalRedis { Jedis redis ->
if (redis) return redis.smembers(key)
}
if (!set) {
log.debug('cache miss: {}', key)
set = closure()
if (set) withOptionalPipeline { pipeline ->
if (pipeline) {
for (obj in set) {
pipeline.sadd(key, obj)
}
if (options?.expire) pipeline.expire(key, options.expire)
}
}
} else {
log.debug('cache hit: {}', key)
}
set
}