Skip to content

Commit badd23b

Browse files
committed
migrado do redis para sqlite, no futuro tera rotinas para limpar caches
1 parent 602fc27 commit badd23b

File tree

9 files changed

+192
-147
lines changed

9 files changed

+192
-147
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ composer.lock
33
.env
44
app/logs/*.log
55
app/cache/*.gz
6+
app/cache/database/*.sql
67
TODO.md
78
node_modules
89

Dockerfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ RUN apt-get update && apt-get install -y \
1111
git \
1212
htop \
1313
libzip-dev \
14-
libhiredis-dev \
15-
&& docker-php-ext-install zip opcache \
16-
&& pecl install redis \
17-
&& docker-php-ext-enable redis opcache \
14+
sqlite3 \
15+
&& docker-php-ext-install zip opcache pdo_sqlite \
16+
&& docker-php-ext-enable opcache \
1817
&& apt-get clean && rm -rf /var/lib/apt/lists/*
1918

2019
# Stage 1: Build stage
@@ -48,8 +47,8 @@ COPY default.conf /etc/nginx/sites-available/default
4847
COPY docker-entrypoint.sh /usr/local/bin/
4948
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
5049

51-
# Create cache and logs folders
52-
RUN mkdir -p /app/cache /app/logs
50+
# Create cache, database, and logs folders
51+
RUN mkdir -p /app/cache /app/cache/database /app/logs
5352

5453
# Configure base permissions for /app directory
5554
RUN chown -R www-data:www-data /app \

app/cache/database/.gitkeep

Whitespace-only changes.

app/cache/database/.sqlite

12 KB
Binary file not shown.

app/config.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@
3838
define('CACHE_DIR', __DIR__ . '/cache');
3939
define('LANGUAGE', $_ENV['LANGUAGE'] ?? 'pt-br');
4040

41-
// Redis connection settings
42-
define('REDIS_HOST', $_ENV['REDIS_HOST'] ?? 'localhost');
43-
define('REDIS_PORT', $_ENV['REDIS_PORT'] ?? 6379);
44-
define('REDIS_PREFIX', $_ENV['REDIS_PREFIX'] ?? 'marreta:');
45-
4641
// Logging configuration
4742
define('LOG_LEVEL', $_ENV['LOG_LEVEL'] ?? 'WARNING'); // DEBUG, INFO, WARNING, ERROR, CRITICAL
4843
define('LOG_DAYS_TO_KEEP', 7);

app/inc/Cache.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Inc\Cache\CacheStorageInterface;
66
use Inc\Cache\DiskStorage;
77
use Inc\Cache\S3Storage;
8-
use Inc\Cache\RedisStorage;
8+
use Inc\Cache\SQLiteStorage;
99

1010
/**
1111
* System cache management with multiple storage backends (disk/S3)
@@ -17,18 +17,18 @@ class Cache
1717
/** @var CacheStorageInterface Cache storage implementation */
1818
private $storage;
1919

20-
/** @var RedisStorage Redis instance for file counting */
21-
private $redisStorage;
20+
/** @var SQLiteStorage SQLite instance for file counting */
21+
private $sqliteStorage;
2222

2323
/**
2424
* Initializes storage based on configuration
2525
* Uses S3Storage if configured and enabled
26-
* Defaults to DiskStorage otherwise
26+
* Defaults to SQLiteStorage otherwise (which delegates to DiskStorage)
2727
*/
2828
public function __construct()
2929
{
30-
$this->redisStorage = new RedisStorage(CACHE_DIR);
31-
30+
$this->sqliteStorage = new SQLiteStorage(CACHE_DIR);
31+
3232
if (defined('S3_CACHE_ENABLED') && S3_CACHE_ENABLED === true) {
3333
$this->storage = new S3Storage([
3434
'key' => S3_ACCESS_KEY,
@@ -40,14 +40,14 @@ public function __construct()
4040
'endpoint' => defined('S3_ENDPOINT') ? S3_ENDPOINT : null
4141
]);
4242
} else {
43-
$this->storage = new DiskStorage(CACHE_DIR);
43+
$this->storage = $this->sqliteStorage;
4444
}
4545
}
4646

4747
/** Gets total number of cached files */
4848
public function getCacheFileCount(): int
4949
{
50-
return $this->redisStorage->countCacheFiles();
50+
return $this->sqliteStorage->countCacheFiles();
5151
}
5252

5353
/**

app/inc/Cache/RedisStorage.php

Lines changed: 0 additions & 128 deletions
This file was deleted.

0 commit comments

Comments
 (0)