5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-29 16:16:22 +00:00

aplicar la caché a los valores de referencia también

This commit is contained in:
f 2020-11-16 19:17:40 -03:00
parent 781cba24de
commit 90a92ec25d
2 changed files with 7 additions and 5 deletions

View file

@ -20,7 +20,7 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type,
end end
def cache_version def cache_version
value.hash.to_s value.hash.to_s + values.hash.to_s
end end
def cache_key_with_version def cache_key_with_version

View file

@ -291,11 +291,13 @@ class Site < ApplicationRecord
# @param attr [Symbol|String] El atributo a buscar # @param attr [Symbol|String] El atributo a buscar
# @return Array # @return Array
def everything_of(attr, lang: nil) def everything_of(attr, lang: nil)
attr = attr.to_sym Rails.cache.fetch("#{cache_key_with_version}/everything_of/#{lang}/#{attr}", expires_in: 1.hour) do
attr = attr.to_sym
posts(lang: lang).flat_map do |p| posts(lang: lang).flat_map do |p|
p[attr].value if p.attribute? attr p[attr].value if p.attribute? attr
end.uniq.compact end.uniq.compact
end
end end
# Poner en la cola de compilación # Poner en la cola de compilación