Skip to content

Commit 72ae3fd

Browse files
committed
removed deprecated stuff
1 parent ca4a694 commit 72ae3fd

5 files changed

Lines changed: 7 additions & 88 deletions

File tree

src/Caching/Cache.php

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -157,29 +157,18 @@ public function save(mixed $key, mixed $data, array $dependencies = null): mixed
157157
{
158158
$key = $this->generateKey($key);
159159

160-
if ($data instanceof \Closure) {
161-
trigger_error(__METHOD__ . '() closure argument is deprecated.', E_USER_WARNING);
162-
$this->storage->lock($key);
163-
try {
164-
$data = $data(...[&$dependencies]);
165-
} catch (\Throwable $e) {
166-
$this->storage->remove($key);
167-
throw $e;
168-
}
169-
}
170-
171160
if ($data === null) {
172161
$this->storage->remove($key);
173162
return null;
163+
}
164+
165+
$dependencies = $this->completeDependencies($dependencies);
166+
if (isset($dependencies[self::EXPIRATION]) && $dependencies[self::EXPIRATION] <= 0) {
167+
$this->storage->remove($key);
174168
} else {
175-
$dependencies = $this->completeDependencies($dependencies);
176-
if (isset($dependencies[self::EXPIRATION]) && $dependencies[self::EXPIRATION] <= 0) {
177-
$this->storage->remove($key);
178-
} else {
179-
$this->storage->write($key, $data, $dependencies);
180-
}
181-
return $data;
169+
$this->storage->write($key, $data, $dependencies);
182170
}
171+
return $data;
183172
}
184173

185174

src/Caching/Storages/FileStorage.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ class FileStorage implements Nette\Caching\Storage
5050
/** probability that the clean() routine is started */
5151
public static float $gcProbability = 0.001;
5252

53-
/** @deprecated */
54-
public static $useDirectories = true;
55-
5653
private string $dir;
5754

5855
private ?Journal $journal;

src/Caching/Storages/NewMemcachedStorage.php

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

tests/Caching/Cache.save.phpt

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,38 +25,3 @@ $cache->save('key', 'value', $dependencies);
2525
$res = $cache->load('key');
2626
Assert::same('value', $res['data']);
2727
Assert::same($dependencies, $res['dependencies']);
28-
29-
30-
// save callback return value
31-
$storage = new testStorage;
32-
$cache = new Cache($storage, 'ns');
33-
34-
@$cache->save('key', fn () => 'value');
35-
36-
$res = $cache->load('key');
37-
Assert::same('value', $res['data']);
38-
Assert::same([], $res['dependencies']);
39-
40-
41-
// save callback return value with dependencies
42-
$storage = new testStorage;
43-
$cache = new Cache($storage, 'ns');
44-
$dependencies = [Cache::TAGS => ['tag']];
45-
46-
@$cache->save('key', fn () => 'value', $dependencies);
47-
48-
$res = $cache->load('key');
49-
Assert::same('value', $res['data']);
50-
Assert::same($dependencies, $res['dependencies']);
51-
52-
53-
// do not save already expired data
54-
$storage = new testStorage;
55-
$cache = new Cache($storage, 'ns');
56-
$dependencies = [Cache::EXPIRATION => new DateTime];
57-
58-
@$res = $cache->save('key', fn () => 'value', $dependencies);
59-
Assert::same('value', $res);
60-
61-
$res = $cache->load('key');
62-
Assert::null($res);

tests/Storages/FileStorage.closure.phpt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,3 @@ $value = range("\x00", "\xFF");
2121
$cache = new Cache(new FileStorage(getTempDir()));
2222

2323
Assert::null($cache->load($key));
24-
25-
26-
// Writing cache using Closure...
27-
$res = @$cache->save($key, fn () => $value);
28-
29-
Assert::same($res, $value);
30-
31-
Assert::same($cache->load($key), $value);
32-
33-
34-
// Removing from cache using null callback...
35-
@$cache->save($key, fn () => null);
36-
37-
Assert::null($cache->load($key));

0 commit comments

Comments
 (0)