Class: Lutaml::Store::HttpCacheConfig
- Inherits:
-
Object
- Object
- Lutaml::Store::HttpCacheConfig
- Includes:
- Model::Serialize
- Defined in:
- lib/lutaml/store/http_cache_config.rb
Instance Method Summary collapse
- #cache_key_for(key) ⇒ Object
- #should_ignore_query_param?(param) ⇒ Boolean
- #should_ignore_vary_header?(header) ⇒ Boolean
- #to_adapter_config ⇒ Object
- #validate! ⇒ Object
Instance Method Details
#cache_key_for(key) ⇒ Object
34 35 36 |
# File 'lib/lutaml/store/http_cache_config.rb', line 34 def cache_key_for(key) "#{cache_key_prefix}:#{key}" end |
#should_ignore_query_param?(param) ⇒ Boolean
38 39 40 |
# File 'lib/lutaml/store/http_cache_config.rb', line 38 def should_ignore_query_param?(param) ignore_query_params.include?(param.to_s) end |
#should_ignore_vary_header?(header) ⇒ Boolean
42 43 44 |
# File 'lib/lutaml/store/http_cache_config.rb', line 42 def should_ignore_vary_header?(header) vary_ignore_headers.map(&:downcase).include?(header.to_s.downcase) end |
#to_adapter_config ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/lutaml/store/http_cache_config.rb', line 22 def to_adapter_config base_config = { type: adapter_type.to_sym, **.transform_keys(&:to_sym) } # Add compression if enabled base_config[:compression] = true if enable_compression base_config end |
#validate! ⇒ Object
46 47 48 49 50 |
# File 'lib/lutaml/store/http_cache_config.rb', line 46 def validate! raise ArgumentError, "default_ttl must be positive" if default_ttl <= 0 raise ArgumentError, "max_entries must be positive" if max_entries <= 0 raise ArgumentError, "adapter_type cannot be empty" if adapter_type.nil? || adapter_type.empty? end |