5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-07-01 22:36:08 +00:00

invalidar la caché si el post cambia

This commit is contained in:
f 2020-05-12 12:50:22 -03:00
parent e65c8e163b
commit 3fa6ca4e1e

View file

@ -75,10 +75,21 @@ class Post < OpenStruct
'posts/' + uuid.value
end
def cache_version
updated_at.utc.to_s(:usec)
end
# Agregar el timestamp para saber si cambió, siguiendo el módulo
# ActiveRecord::Integration
def cache_key_with_version
cache_key + '-' + cache_version
end
# TODO: Convertir a UUID?
def id
path.basename
end
alias to_param id
def updated_at
File.mtime(path.absolute)