From a0580ad085c2a20134599c1388d3bd376bcb3346 Mon Sep 17 00:00:00 2001 From: Lewis Dale Date: Sun, 27 Aug 2023 22:03:56 +0100 Subject: [PATCH] Enforce uniqueness --- src/Lib/SqliteImageDb.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Lib/SqliteImageDb.php b/src/Lib/SqliteImageDb.php index e25a0a8..23958f3 100644 --- a/src/Lib/SqliteImageDb.php +++ b/src/Lib/SqliteImageDb.php @@ -24,6 +24,9 @@ class SqliteImageDb implements ImageDb { quality INTEGER NULLABLE, content TEXT NOT NULL )'); + + // Create a unique index on the path and params + $this->db->exec('CREATE UNIQUE INDEX IF NOT EXISTS images_path_width_height_quality ON images (path, width, height, quality)'); } public function findImage(string $path, ResizeParams $params): Image | null {