mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
make the cache adapter as config options and use them when calling the cache lib
This commit is contained in:
@@ -384,14 +384,36 @@ $config['error_views_path'] = '';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Directory Path
|
||||
| Cache Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Leave this BLANK unless you would like to set something other than the default
|
||||
| application/cache/ directory. Use a full server path with trailing slash.
|
||||
| CodeIgniter supports multiple cache adapters to improve application performance
|
||||
| by storing frequently accessed data.
|
||||
|
|
||||
| 'cache_path'
|
||||
| Directory path for file-based caching. Leave BLANK to use the default
|
||||
| application/cache/ directory. Use absolute paths with trailing slash.
|
||||
| Must be writable by the web server (typically www-data or apache user).
|
||||
| Example: /var/cache/wavelog/ or /tmp/wavelog_cache/
|
||||
|
|
||||
| 'cache_adapter'
|
||||
| The primary cache adapter to use. Options include:
|
||||
| - 'file' : File-based caching (default, works everywhere)
|
||||
| - 'redis' : Redis in-memory cache (requires Redis server & extension)
|
||||
| - 'memcached' : Memcached (requires Memcached server & extension)
|
||||
| - 'apc' : APC/APCu in-memory cache (requires APCu extension)
|
||||
| - 'wincache' : Windows Cache (requires WinCache extension)
|
||||
|
|
||||
| 'cache_backup'
|
||||
| Fallback adapter if primary adapter fails or is unavailable.
|
||||
| Recommended: 'file' as a safe fallback option
|
||||
|
|
||||
| Note: Redis configuration is stored separately in application/config/redis.php
|
||||
|
|
||||
*/
|
||||
$config['cache_path'] = '';
|
||||
$config['cache_adapter'] = 'file';
|
||||
$config['cache_backup'] = 'file';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -1255,7 +1255,7 @@ class API extends CI_Controller {
|
||||
}
|
||||
|
||||
// Load cache driver
|
||||
$this->load->driver('cache', ['adapter' => 'file']);
|
||||
$this->load->driver('cache', ['adapter' => $this->config->item('cache_adapter'), 'backup' => $this->config->item('cache_backup')]);
|
||||
|
||||
// Create cache key
|
||||
$cache_key = "wp_stats_{$station_id}";
|
||||
|
||||
@@ -126,7 +126,7 @@ class Contestcalendar extends CI_Controller {
|
||||
|
||||
private function getRssData() {
|
||||
|
||||
$this->load->driver('cache', array('adapter' => 'file', 'backup' => 'file'));
|
||||
$this->load->driver('cache', ['adapter' => $this->config->item('cache_adapter'), 'backup' => $this->config->item('cache_backup')]);
|
||||
|
||||
if (!$rssRawData = $this->cache->get('RssRawContestCal')) {
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class Dxcalendar extends CI_Controller {
|
||||
|
||||
$data['page_title'] = __("DX Calendar");
|
||||
|
||||
$this->load->driver('cache', array('adapter' => 'file', 'backup' => 'file'));
|
||||
$this->load->driver('cache', ['adapter' => $this->config->item('cache_adapter'), 'backup' => $this->config->item('cache_backup')]);
|
||||
$rssUrl = 'http://www.ng3k.com/adxo.xml';
|
||||
if (!$rssRawData = $this->cache->get('RssRawDxCal')) {
|
||||
$rssRawData = file_get_contents($rssUrl, true);
|
||||
|
||||
@@ -18,7 +18,7 @@ class Sattimers extends CI_Controller {
|
||||
|
||||
$url = 'https://www.df2et.de/tevel/api2.php?grid='.strtoupper($this->stations->find_gridsquare());
|
||||
|
||||
$this->load->driver('cache', array('adapter' => 'file', 'backup' => 'file'));
|
||||
$this->load->driver('cache', ['adapter' => $this->config->item('cache_adapter'), 'backup' => $this->config->item('cache_backup')]);
|
||||
if (!$RawData = $this->cache->get('SatTimers'.strtoupper($this->stations->find_gridsquare()))) {
|
||||
$RawData = file_get_contents($url, true);
|
||||
$this->cache->save('SatTimers'.strtoupper($this->stations->find_gridsquare()), $RawData, (60*1));
|
||||
|
||||
@@ -15,7 +15,7 @@ class Rate_limit {
|
||||
|
||||
public function __construct() {
|
||||
$this->CI =& get_instance();
|
||||
$this->CI->load->driver('cache', ['adapter' => 'file']);
|
||||
$this->CI->load->driver('cache', ['adapter' => $this->CI->config->item('cache_adapter'), 'backup' => $this->CI->config->item('cache_backup')]);
|
||||
|
||||
// Load rate limit config - if not set or empty, rate limiting is disabled
|
||||
$this->rate_limits = $this->CI->config->item('api_rate_limits');
|
||||
|
||||
@@ -53,7 +53,7 @@ class Dxcluster_model extends CI_Model {
|
||||
|
||||
// Only load cache driver if caching is enabled
|
||||
if ($cache_band_enabled || $cache_worked_enabled) {
|
||||
$this->load->driver('cache', array('adapter' => 'file', 'backup' => 'file'));
|
||||
$this->load->driver('cache', ['adapter' => $this->config->item('cache_adapter'), 'backup' => $this->config->item('cache_backup')]);
|
||||
|
||||
// Garbage collection: 1% chance to clean expired cache files
|
||||
// Only needed when worked cache is enabled (creates many per-callsign files)
|
||||
|
||||
@@ -2716,7 +2716,7 @@ class Logbook_model extends CI_Model {
|
||||
// Load cache driver for file caching
|
||||
$cache_enabled = $this->config->item('enable_dxcluster_file_cache_worked') === true;
|
||||
if ($cache_enabled && !isset($this->cache)) {
|
||||
$this->load->driver('cache', array('adapter' => 'file', 'backup' => 'file'));
|
||||
$this->load->driver('cache', ['adapter' => $this->config->item('cache_adapter'), 'backup' => $this->config->item('cache_backup')]);
|
||||
}
|
||||
|
||||
// Cache TTL in seconds (15 minutes = 900 seconds)
|
||||
|
||||
@@ -323,7 +323,7 @@ class Dxcc {
|
||||
*/
|
||||
function read_data($date = NULL) {
|
||||
$CI = &get_instance();
|
||||
$CI->load->driver('cache', ['adapter' => 'file']);
|
||||
$CI->load->driver('cache', ['adapter' => $CI->config->item('cache_adapter'), 'backup' => $CI->config->item('cache_backup')]);
|
||||
|
||||
// DXCC Exceptions
|
||||
$cache_key = 'dxcc_exceptions_' . ($date ?? 'all');
|
||||
|
||||
Reference in New Issue
Block a user