Class: Jekyll::Cache::FileStore

Inherits:
ActiveSupport::Cache::FileStore
  • Object
show all
Defined in:
lib/jekyll/cache/file_store.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ <EnvyGeeks::Cache>

– Overrides the default method so that we can simply

pass in the name of the directory we want to store
cache files inside of



24
25
26
27
# File 'lib/jekyll/cache/file_store.rb', line 24

def initialize(dir)
  super(Jekyll.cache_dir.join(dir))
  self.logger = Cache.logger
end

Class Method Details

.clearObject



13
14
15
# File 'lib/jekyll/cache/file_store.rb', line 13

def self.clear
  Cache.method(:clear).call
end

Instance Method Details

#fetch(key, **opts) ⇒ <Any>

– Overrides ‘fetch` so that we can automatically

(immediately) expire if we are in development, without
the need for any one class to carry expirey data.

Parameters:

  • key (String, Symbol)

    the cache key.

Returns:

  • (<Any>)

    the cached value.



44
45
46
47
48
49
50
# File 'lib/jekyll/cache/file_store.rb', line 44

def fetch(key, **opts)
  opts[:expires_in] = expires_in unless opts.key?(:expires_in)
  return yield if opts[:expires_in] == 0.minutes
  super(key, **opts) do
    yield
  end
end

#middlewareObject

– So that users don’t freak out. –

Returns:

  • nil



33
34
35
# File 'lib/jekyll/cache/file_store.rb', line 33

def middleware
  nil
end