How to use [cache.try-get]

The reference page of cache.try-get has its arguments, constraints and declaration.

This slot checks your cache to look for an item matching your specified key, and if not found, it will invoke its [.lambda] argument, and save its returned value to the cache with the specified key, before returning the created item to caller.

cache.try-get:cache-key
   expiration:5
   .lambda
      return:Howdy world

If you are using the default memory based cache, then this slot is implemented in such a way that only the first invocation towards the specified key will actually execute your [.lambda] object, allowing you to have very expensive executions to create your items, that you want to store into the cache, without experiencing race conditions, or having more than one thread actually create the item and store into the cache. Notice, this is not true if you are using an out of process cache implementation, such as the one found in the “magic.data.cql” project. This should in general be your “goto slot” whenever you want to use the cache slots in this project.