Skip to content

Instantly share code, notes, and snippets.

@Ke- Ke-/cache_method.lasso
Last active May 9, 2016

Embed
What would you like to do?
Used either for a singleton effect or just for performance.
// Cache method result on a thread level
define cache_method(c::capture = givenblock) => {
#c->isnota(::capture) ? return #c
local(v) = #c->self ? #c->self->type->asstring + '.' + #c->methodname | #c->methodname
var(#v)->isa(::null) ? var(#v) = #c->detach & invoke
return var(#v)
}
@Ke-

This comment has been minimized.

Copy link
Owner Author

Ke- commented Jan 22, 2015

define current_user => cache_method => {
return user(session->val(::user_id) || 0)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.