Skip to content

Commit 196e429

Browse files
feature #58109 [Lock] Add NullStore (xabbuh)
This PR was merged into the 7.2 branch. Discussion ---------- [Lock] Add `NullStore` | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | | License | MIT Commits ------- dd0721a add NullStore
2 parents 52f1436 + dd0721a commit 196e429

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

src/Symfony/Component/Lock/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.2
5+
---
6+
7+
* Add `NullStore`
8+
49
7.0
510
---
611

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Lock\Store;
13+
14+
use Symfony\Component\Lock\BlockingSharedLockStoreInterface;
15+
use Symfony\Component\Lock\Key;
16+
17+
class NullStore implements BlockingSharedLockStoreInterface
18+
{
19+
public function save(Key $key): void
20+
{
21+
}
22+
23+
public function delete(Key $key): void
24+
{
25+
}
26+
27+
public function exists(Key $key): bool
28+
{
29+
return false;
30+
}
31+
32+
public function putOffExpiration(Key $key, float $ttl): void
33+
{
34+
}
35+
36+
public function saveRead(Key $key): void
37+
{
38+
}
39+
40+
public function waitAndSaveRead(Key $key): void
41+
{
42+
}
43+
}

src/Symfony/Component/Lock/Store/StoreFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ public static function createStore(#[\SensitiveParameter] object|string $connect
106106

107107
case 'in-memory' === $connection:
108108
return new InMemoryStore();
109+
110+
case 'null' === $connection:
111+
return new NullStore();
109112
}
110113

111114
throw new InvalidArgumentException(\sprintf('Unsupported Connection: "%s".', $connection));

src/Symfony/Component/Lock/Tests/Store/StoreFactoryTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Symfony\Component\Lock\Store\FlockStore;
2121
use Symfony\Component\Lock\Store\InMemoryStore;
2222
use Symfony\Component\Lock\Store\MemcachedStore;
23+
use Symfony\Component\Lock\Store\NullStore;
2324
use Symfony\Component\Lock\Store\PdoStore;
2425
use Symfony\Component\Lock\Store\PostgreSqlStore;
2526
use Symfony\Component\Lock\Store\RedisStore;
@@ -92,5 +93,7 @@ public static function validConnections(): \Generator
9293

9394
yield ['flock', FlockStore::class];
9495
yield ['flock://'.sys_get_temp_dir(), FlockStore::class];
96+
97+
yield ['null', NullStore::class];
9598
}
9699
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy