-
Notifications
You must be signed in to change notification settings - Fork 1
Simple Syntax
Once your server test returns online for all servers you can start to use Memcached. The syntax is very simple and utilises Lasso’s blocks:
memcached('string_example') => 'I was cached on [date].'
memcached('include_example') => file('/file/to/include.inc')
memcached('capture_example') => { return array(1,2,3) }
The given block should be a string, file or capture. Captures should return the value to store when they are invoked. Strings and files are compiled and invoked as Lasso source code. Each block is only invoked if a valid key is not present in the cache.
The core Lasso types are automatically encoded and decoded when they are stored and retrieved from Memcached. The types supported are: null, integer, decimal, string, bytes, pair, array and map.
By default the Memcached client runs in a graceful mode — this means that errors are suppressed and the cached will be skipped if no Memcached servers are unavailable or similar. During development you may find it useful to disable graceful mode:
memcached->graceful = false
You can specify an expiration value in seconds or as a date object.
memcached('expire_60_seconds',60) => 'I was cached on [date].'
memcached('expire_tomorrow',date) => 'I was cached on [date].'
You can also force memcached to refresh the cached item by specify a boolean parameter.
memcached('force_refresh',true) => 'I was cached on [date].'
or
memcached('force_refresh',60,true) => 'I was cached on [date].'