mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 00:56:22 +00:00
invalidar la caché si el post cambia
This commit is contained in:
parent
e65c8e163b
commit
3fa6ca4e1e
1 changed files with 11 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue