class Sprockets::CachedEnvironment
`CachedEnvironment` is a special cached version of `Environment`.
The expection is that all of its file system methods are cached for the instances lifetime. This makes `CachedEnvironment` much faster. This behavior is ideal in production environments where the file system is immutable.
`CachedEnvironment` should not be initialized directly. Instead use `Environment#cached`.
Public Class Methods
new(environment)
click to toggle source
# File lib/sprockets/cached_environment.rb, line 15 def initialize(environment) initialize_configuration(environment) @cache = environment.cache @stats = {} @entries = {} @uris = {} @processor_cache_keys = {} @resolved_dependencies = {} end
Public Instance Methods
cached()
click to toggle source
No-op return self as cached environment.
# File lib/sprockets/cached_environment.rb, line 27 def cached self end
Also aliased as: index
entries(path)
click to toggle source
Internal: Cache
Environment#entries
Calls superclass method
# File lib/sprockets/cached_environment.rb, line 33 def entries(path) @entries[path] ||= super(path) end
load(uri)
click to toggle source
Internal: Cache
Environment#load
Calls superclass method
# File lib/sprockets/cached_environment.rb, line 43 def load(uri) @uris[uri] ||= super(uri) end
processor_cache_key(str)
click to toggle source
Internal: Cache
Environment#processor_cache_key
Calls superclass method
# File lib/sprockets/cached_environment.rb, line 48 def processor_cache_key(str) @processor_cache_keys[str] ||= super(str) end
resolve_dependency(str)
click to toggle source
Internal: Cache
Environment#resolve_dependency
Calls superclass method
# File lib/sprockets/cached_environment.rb, line 53 def resolve_dependency(str) @resolved_dependencies[str] ||= super(str) end
stat(path)
click to toggle source
Internal: Cache
Environment#stat
Calls superclass method
# File lib/sprockets/cached_environment.rb, line 38 def stat(path) @stats[path] ||= super(path) end
Private Instance Methods
config=(config)
click to toggle source
Cache
is immutable, any methods that try to change the runtime config should bomb.
# File lib/sprockets/cached_environment.rb, line 60 def config=(config) raise RuntimeError, "can't modify immutable cached environment" end