Skip to content

Commit e190032

Browse files
committed
WIP
1 parent 093f561 commit e190032

76 files changed

Lines changed: 2131 additions & 4209 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kai-init/laravel-normcache",
3-
"description": "Redis-backed normalized query caching for Laravel Eloquent and Query Builder.",
3+
"description": "Redis-backed normalized query caching for Laravel Eloquent.",
44
"type": "library",
55
"license": "MIT",
66
"authors": [
@@ -61,4 +61,4 @@
6161
}
6262
}
6363
}
64-
}
64+
}

config/normcache.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,10 @@
88

99
'row_ttl' => (int) env('NORMCACHE_ROW_TTL', 604800),
1010
'query_ttl' => (int) env('NORMCACHE_QUERY_TTL', 3600),
11-
'schema_ttl' => (int) env('NORMCACHE_SCHEMA_TTL', 86400),
1211

1312
// Set to 0 to disable automatic result overlays.
1413
'auto_overlay_max_rows' => 1000,
1514

16-
// Each group requires connection, database, and table metadata. Add schema to
17-
// restrict a PostgreSQL or SQL Server match. Types are integer or string.
18-
'primary_keys' => [
19-
// [
20-
// 'connection' => 'pgsql',
21-
// 'database' => 'app',
22-
// 'schema' => 'public',
23-
// 'tables' => [
24-
// 'events' => ['column' => 'event_id', 'type' => 'string'],
25-
// 'orders' => ['column' => 'order_id', 'type' => 'integer'],
26-
// ],
27-
// ],
28-
],
29-
3015
'max_precise_invalidation_keys' => 1000,
3116

3217
'building_lock_ttl' => 5,

pint.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
{
22
"preset": "laravel",
3-
"exclude": [
4-
"docs",
5-
"tests/Benchmark",
6-
"tests/Concerns",
7-
"tests/Fixtures/database"
8-
],
3+
"exclude": [],
94
"rules": {
105
"not_operator_with_successor_space": false,
116
"phpdoc_single_line_var_spacing": false,
12-
"concat_space": {"spacing": "one"},
13-
"function_declaration": {"closure_fn_spacing": "none"}
7+
"concat_space": {
8+
"spacing": "one"
9+
},
10+
"function_declaration": {
11+
"closure_fn_spacing": "none"
12+
}
1413
}
15-
}
14+
}

src/Cache/CacheRuntime.php

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ final class CacheRuntime
1717

1818
private ?float $epochReadAt = null;
1919

20-
private ?string $schemaEpoch = null;
21-
2220
private ?bool $runtimeDisabled = null;
2321

2422
public function __construct(
@@ -123,39 +121,16 @@ public function fail(\Throwable $exception): void
123121
$this->failures->cacheUnavailable($exception);
124122
}
125123

126-
public function schemaEpoch(): string
127-
{
128-
if ($this->schemaEpoch !== null) {
129-
return $this->schemaEpoch;
130-
}
131-
132-
$this->resolveState();
133-
134-
return $this->schemaEpoch ??= $this->store->getRaw($this->keys->schemaEpoch()) ?? '0';
135-
}
136-
137-
public function rememberSchemaEpoch(string $epoch): void
138-
{
139-
$this->schemaEpoch = $epoch;
140-
}
141-
142-
public function forgetSchemaEpoch(): void
143-
{
144-
$this->schemaEpoch = null;
145-
}
146-
147124
/** @return array{0: string, 1: bool} */
148125
private function resolveState(): array
149126
{
150127
if ($this->epoch === null || $this->epochExpired()) {
151128
$epochKey = $this->keys->epoch();
152129
$disabledKey = $this->keys->disabled();
153-
$schemaEpochKey = $this->keys->schemaEpoch();
154-
$values = $this->store->mget([$epochKey, $disabledKey, $schemaEpochKey]);
130+
$values = $this->store->mget([$epochKey, $disabledKey]);
155131
$this->epoch = $values[$epochKey] ?? '0';
156132
$this->epochReadAt = microtime(true);
157133
$this->runtimeDisabled ??= ($values[$disabledKey] ?? null) !== null;
158-
$this->schemaEpoch ??= $values[$schemaEpochKey] ?? '0';
159134
}
160135

161136
return [$this->epoch, $this->runtimeDisabled ?? false];

src/Cache/CacheStateResolver.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ public function __construct(
1515
private CacheKeyBuilder $keys,
1616
) {}
1717

18-
/**
19-
* Feed the values back to resolve() as $prefetched; unmatched arguments there
20-
* would silently resolve missing keys to version '0'.
21-
*
22-
* @return list<string>
23-
*/
2418
public function pendingStateKeys(QueryPlan $plan, string $namespace): array
2519
{
2620
return $this->pendingKeys($plan, $namespace)['all'];

0 commit comments

Comments
 (0)