Class: Dragonfly::Cache::Manager
- Inherits:
-
Object
- Object
- Dragonfly::Cache::Manager
- Extended by:
- Forwardable
- Defined in:
- lib/dragonfly/cache/manager.rb
Constant Summary collapse
- MIN_SHA_SIZE =
2
- MAX_SHA_SIZE =
Length of SHA identifier generated by Dragonfly
16
Instance Attribute Summary collapse
-
#map ⇒ Object
readonly
Returns the value of attribute map.
-
#plugin ⇒ Object
readonly
Returns the value of attribute plugin.
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
- #cache(job) ⇒ Object
-
#initialize(plugin) ⇒ Manager
constructor
A new instance of Manager.
- #job_options(job) ⇒ Object
- #valid?(job, uri) ⇒ Boolean
Constructor Details
Instance Attribute Details
#map ⇒ Object (readonly)
Returns the value of attribute map.
14 15 16 |
# File 'lib/dragonfly/cache/manager.rb', line 14 def map @map end |
#plugin ⇒ Object (readonly)
Returns the value of attribute plugin.
14 15 16 |
# File 'lib/dragonfly/cache/manager.rb', line 14 def plugin @plugin end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
14 15 16 |
# File 'lib/dragonfly/cache/manager.rb', line 14 def storage @storage end |
Instance Method Details
#cache(job) ⇒ Object
24 25 26 27 28 |
# File 'lib/dragonfly/cache/manager.rb', line 24 def cache(job) return @map[job.sha] if @map.key?(job.sha) store(job, yield) end |
#job_options(job) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/dragonfly/cache/manager.rb', line 37 def (job) { shaish: shaish(job), normalized_name: normalized_name(job) } end |
#valid?(job, uri) ⇒ Boolean
30 31 32 33 34 35 |
# File 'lib/dragonfly/cache/manager.rb', line 30 def valid?(job, uri) valid = (@map.key?(job.sha) && @map[job.sha] == uri) || !@map.key?(job.sha) valid &= (@map.value?(uri) && @map.key(uri) == job.sha) || !@map.value?(uri) increase_sha_size! unless valid valid end |