Class: Primer::Octicon::Cache
- Inherits:
-
Object
- Object
- Primer::Octicon::Cache
- Defined in:
- app/lib/primer/octicon/cache.rb
Overview
:nodoc:
Constant Summary collapse
- LOOKUP =
rubocop:disable Style/MutableConstant
{}
- PRELOADED_ICONS =
Preload the top 20 used icons.
[:alert, :check, :"chevron-down", :paste, :clock, :"dot-fill", :info, :"kebab-horizontal", :link, :lock, :mail, :pencil, :plus, :question, :repo, :search, :"shield-lock", :star, :trash, :x].freeze
Class Method Summary collapse
- .clear! ⇒ Object
- .get_key(**kwargs) ⇒ Object
-
.limit ⇒ Object
Cache size limit.
- .preload! ⇒ Object
- .read(key) ⇒ Object
- .set(key, value) ⇒ Object
Class Method Details
.clear! ⇒ Object
33 34 35 |
# File 'app/lib/primer/octicon/cache.rb', line 33 def clear! LOOKUP.clear end |
.get_key(**kwargs) ⇒ Object
12 13 14 15 |
# File 'app/lib/primer/octicon/cache.rb', line 12 def get_key(**kwargs) correct_key_args?(**kwargs) kwargs.hash end |
.limit ⇒ Object
Cache size limit.
22 23 24 |
# File 'app/lib/primer/octicon/cache.rb', line 22 def limit 500 end |
.preload! ⇒ Object
37 38 39 |
# File 'app/lib/primer/octicon/cache.rb', line 37 def preload! PRELOADED_ICONS.each { |icon| Primer::OcticonComponent.new(icon: icon) } end |
.read(key) ⇒ Object
17 18 19 |
# File 'app/lib/primer/octicon/cache.rb', line 17 def read(key) LOOKUP[key] end |