Skip to content

Instantly share code, notes, and snippets.

@svenfuchs
Created August 28, 2008 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svenfuchs/29ec378f9a766b34eb11 to your computer and use it in GitHub Desktop.
Save svenfuchs/29ec378f9a766b34eb11 to your computer and use it in GitHub Desktop.
module I18n
module Backend
class Caching
attr_accessor :backend
def translate(*args)
result = read_cache(args) and return result
write_cache args, backend.translate(*args)
end
protected
def cache
@cache ||= {}
end
def read_cache(key)
@cache[key]
end
def write_cache(key, result)
@cache[key] = result
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment