Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [Obtaining a Cache Instance](#obtaining-a-cache-instance)
- [Retrieving Items From the Cache](#retrieving-items-from-the-cache)
- [Storing Items in the Cache](#storing-items-in-the-cache)
- [Extending Item Lifetime](#extending-item-lifetime)
- [Removing Items From the Cache](#removing-items-from-the-cache)
- [The Cache Helper](#the-cache-helper)
- [Atomic Locks](#atomic-locks)
Expand Down Expand Up @@ -287,6 +288,21 @@ The `add` method will only add the item to the cache if it does not already exis
Cache::add('key', 'value', $seconds);
```

<a name="extending-item-lifetime"></a>
### Extending Item Lifetime

The `touch` method allows you to extend the lifetime (TTL) of an existing cache item. The `touch` method will return `true` if the cache item exists and its expiration time was successfully extended. If the item does not exist in the cache, the method will return `false`:

```php
Cache::touch('key', 3600);
```

You may provide a `DateTimeInterface`, `DateInterval`, or `Carbon` instance to specify an exact expiration time:

```php
Cache::touch('key', now()->addHours(2));
```

<a name="storing-items-forever"></a>
#### Storing Items Forever

Expand Down