Skip to content

Commit 5997c55

Browse files
committed
feat: update cache usage
1 parent 5be1f89 commit 5997c55

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

composer.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ php8.4 /usr/local/bin/composer install --no-dev
99
/home/forge/.bun/bin/bun install
1010

1111
# Tempest
12-
php8.4 tempest cache:clear --all
12+
php8.4 tempest cache:clear --internal --all
1313
php8.4 tempest discovery:generate
1414
php8.4 tempest migrate:up --force
1515
php8.4 tempest static:clean --force

src/Web/Analytics/ParsePackagistCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Tempest\Console\HasConsole;
99
use Tempest\Console\Schedule;
1010
use Tempest\Console\Scheduler\Every;
11+
use Tempest\DateTime\Duration;
1112
use Tempest\HttpClient\HttpClient;
1213
use Throwable;
1314

@@ -56,8 +57,8 @@ public function __invoke(): void
5657
try {
5758
$data = $this->cache->resolve(
5859
key: "packagist-{$package}",
59-
cache: fn () => json_decode($this->httpClient->get($url)->body, associative: true),
60-
expiresAt: new DateTimeImmutable('+ 30 minutes'),
60+
callback: fn () => json_decode($this->httpClient->get($url)->body, associative: true),
61+
expiration: Duration::minutes(30),
6162
);
6263

6364
event(new PackageDownloadsListed(

src/Web/Blog/BlogController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public function rss(
4747
): Response {
4848
$xml = $cache->resolve(
4949
key: 'rss',
50-
cache: fn () => $this->renderRssFeed($repository->all(loadContent: true)),
51-
expiresAt: DateTime::now()->plusHours(1),
50+
callback: fn () => $this->renderRssFeed($repository->all(loadContent: true)),
51+
expiration: DateTime::now()->plusHours(1),
5252
);
5353

5454
return new Ok($xml)

src/Web/Documentation/content/main/2-features/06-cache.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: "The cache component is based on Symfony's Cache, providing access
77

88
By default, Tempest uses a filesystem-based caching strategy. You may use a different cache back-end by creating a configuration file for the desired cache adapter.
99

10-
For instance, you may use Redis as your cache back-end by creating a `cache.config.php` file returning an instance of {b`Tempest\Cache\Config\RedisCacheConfig`}:
10+
<!-- For instance, you may use Redis as your cache back-end by creating a `cache.config.php` file returning an instance of {b`Tempest\Cache\Config\RedisCacheConfig`}:
1111
1212
```php src/cache.config.php
1313
return new RedisCacheConfig(
@@ -18,7 +18,7 @@ return new RedisCacheConfig(
1818
);
1919
```
2020
21-
In this example, the Redis credentials are specified in the `.env`, so a different bucket and credentials can be configured depending on the environment. Of course, you may use different, more specific environment variables if needed.
21+
In this example, the Redis credentials are specified in the `.env`, so a different bucket and credentials can be configured depending on the environment. Of course, you may use different, more specific environment variables if needed. -->
2222

2323
Once your cache is configured, you may interact with it by using the {`Tempest\Cache\Cache`} interface. This is usually done through [dependency injection](../1-essentials/05-container.md#injecting-dependencies):
2424

0 commit comments

Comments
 (0)