mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 01:01:39 -05:00
Add cache cleaning and preheating
This commit is contained in:
parent
6eb3341133
commit
d640af4036
3 changed files with 34 additions and 2 deletions
|
|
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
# 0.21.1 - 2024-12-23
|
||||
|
||||
### Added
|
||||
|
||||
- Cache cleaning and preheating upon application start.
|
||||
|
||||
# 0.21.0 - 2024-12-20
|
||||
|
||||
⚠️ This release introduces a breaking change. ⚠️
|
||||
|
|
|
|||
24
app/services/cache/clean.rb
vendored
Normal file
24
app/services/cache/clean.rb
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Cache::Clean
|
||||
class << self
|
||||
def call
|
||||
Rails.logger.info('Cleaning cache...')
|
||||
delete_version_cache
|
||||
delete_years_tracked_cache
|
||||
Rails.logger.info('Cache cleaned')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def delete_version_cache
|
||||
Rails.cache.delete(CheckAppVersion::VERSION_CACHE_KEY)
|
||||
end
|
||||
|
||||
def delete_years_tracked_cache
|
||||
User.find_each do |user|
|
||||
Rails.cache.delete("dawarich/user_#{user.id}_years_tracked")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -6,6 +6,8 @@ require_relative 'application'
|
|||
# Initialize the Rails application.
|
||||
Rails.application.initialize!
|
||||
|
||||
# Clear the cache of the application version
|
||||
# Clear the cache
|
||||
Cache::Clean.call
|
||||
|
||||
Rails.cache.delete(CheckAppVersion::VERSION_CACHE_KEY)
|
||||
# Preheat the cache
|
||||
Cache::PreheatingJob.perform_later
|
||||
|
|
|
|||
Loading…
Reference in a new issue