Created
December 16, 2013 19:47
-
-
Save adam000/7993148 to your computer and use it in GitHub Desktop.
I had a cool thought: what if you used metatables to make a really cool caching scheme? If it hits the `__index` metatable, you return a function that'll add a key-value pair, otherwise you return the value. Don't have time to work on it right now, so I'm just posting this barebones gist until I get around to it.
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
#!/usr/bin/env lua | |
-- Get the cache singleton | |
function getCache() | |
-- TODO | |
end | |
-- Metatable function that returns a function to add to the cache |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment