You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CACHE_IMPLEMENTATION_SUMMARY.md
+12-11Lines changed: 12 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,16 @@
1
1
# Find Method Caching Implementation Summary
2
2
3
3
## Overview
4
-
This implementation adds efficient caching to the `find` method in the Database class using FNV164 hashing for consistent cache keys and version tracking for O(1) cache invalidation.
4
+
This implementation adds efficient caching to the `find` method in the Database class using xxh3 hashing for consistent cache keys and version tracking for O(1) cache invalidation.
5
5
6
6
## Key Features
7
7
8
-
### 1. FNV164 Hash Function
8
+
### 1. xxh3 Hash Function
9
9
-**Purpose**: Generate consistent and efficient hash keys for complex query parameters
10
-
-**Implementation**: 64-bit FNV-1a hash algorithm with PHP-specific optimizations
11
-
-**Location**: `fnv164Hash()` method in Database.php
12
-
-**Benefits**: Fast, consistent hashing with good distribution characteristics
10
+
-**Implementation**: PHP's built-in xxh3 hash algorithm via `hash()` function (PHP 8.1+)
11
+
-**Fallback**: SHA256 for PHP versions < 8.1
12
+
-**Location**: `generateCacheHash()` method in Database.php
13
+
-**Benefits**: Extremely fast, well-tested hashing with excellent distribution characteristics
13
14
14
15
### 2. Version Tracking for O(1) Invalidation
15
16
-**Purpose**: Enable aggressive cache invalidation without expensive cache scanning
@@ -18,7 +19,7 @@ This implementation adds efficient caching to the `find` method in the Database
18
19
-**Benefits**: O(1) invalidation time complexity
19
20
20
21
### 3. Find Method Caching
21
-
-**Cache Key Generation**: Uses FNV164 hash of all query parameters plus collection version
22
+
-**Cache Key Generation**: Uses xxh3 hash of all query parameters plus collection version
22
23
-**Cache Storage**: Results are stored as arrays and converted back to Document objects on retrieval
23
24
-**Cache Validation**: Version-based keys ensure stale data is never returned
24
25
-**Safety**: Only caches results without relationships to avoid incomplete data
@@ -33,9 +34,8 @@ This implementation adds efficient caching to the `find` method in the Database
0 commit comments