Skip to content

Instantly share code, notes, and snippets.

@adam000
Created December 16, 2013 19:47
Show Gist options
  • Save adam000/7993148 to your computer and use it in GitHub Desktop.
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.
#!/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