Sha256: 6ae3420d374f494fe125a96a28a3746a7e735acdf50e8a83d17f867e5819b3b4
Contents?: true
Size: 1.07 KB
Versions: 99
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module Primer module Octicon # :nodoc: class Cache LOOKUP = {} # Preload the top 20 used icons. PRELOADED_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 << self def get_key(symbol:, size:, width: nil, height: nil) attrs = { symbol: symbol, size: size, width: width, height: height } attrs.compact! attrs.hash end def read(key) LOOKUP[key] end # Cache size limit. def limit 500 end def set(key, value) LOOKUP[key] = value # Remove first item when the cache is too large. LOOKUP.shift if LOOKUP.size > limit end def clear! LOOKUP.clear end def preload! PRELOADED_ICONS.each { |icon| Primer::Beta::Octicon.new(icon: icon) } end end end end end
Version data entries
99 entries across 99 versions & 2 rubygems