Skip to content

Instantly share code, notes, and snippets.

@Ozsie
Last active May 6, 2018 06:30
Show Gist options
  • Save Ozsie/059a55f7d9e42ed82a5ec2cf941b49fa to your computer and use it in GitHub Desktop.
Save Ozsie/059a55f7d9e42ed82a5ec2cf941b49fa to your computer and use it in GitHub Desktop.
Controller
@RestController
@RequestMapping(value = ["/controller"])
class Controller {
@Autowired lateinit var cache: Cache
@GetMapping(path = ["{key}"])
fun getStuff(@PathVariable("key") key: String) = cache.getUUID(key)
}
@CacheConfig(cacheNames = ["map"])
@Service
class Cache {
@Cacheable(value = ["map"], key = "#key")
fun getUUID(key: String): UUID? = UUID.randomUUID().also { println("Generated $it") }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment