Last active
May 9, 2016 22:13
-
-
Save Ke-/5a631f50eb5366b9cc35 to your computer and use it in GitHub Desktop.
Used either for a singleton effect or just for performance.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
define current_user => cache_method => {
return user(session->val(::user_id) || 0)
}