Skip to content

Commit a4b7371

Browse files
Update README.md
1 parent 7adfcfb commit a4b7371

File tree

1 file changed

+5
-46
lines changed

1 file changed

+5
-46
lines changed

README.md

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ Or manually update `require` block of `composer.json` and run `composer update`.
2020
```json
2121
{
2222
"require": {
23-
"dragon-code/laravel-cache": "^3.11"
23+
"dragon-code/laravel-cache": "^4.0"
2424
}
2525
}
2626
```
2727

28+
## Upgrade Guide
29+
30+
Information on upgrade from version 3 to 4 is located in the [UPGRADE.md](UPGRADE.md) file.
31+
2832
## Using
2933

3034
### Keys And Tags
@@ -361,51 +365,6 @@ Cache::make()->ttl((object) ['foo' => 'Foo'], false);
361365
If the value is not found, the [default value](config/cache.php) will be taken, which you can also override in
362366
the [configuration file](config/cache.php).
363367

364-
##### With Contract
365-
366-
Starting with version [`2.9.0`](https://github.com/TheDragonCode/laravel-cache/releases/tag/v2.9.0), we added the
367-
ability to dynamically specify TTLs in objects. To do this, you
368-
need to implement the `DragonCode\Contracts\Cache\Ttl` contract into your object and add a method that returns one of
369-
the following types of variables: `DateTimeInterface`
370-
, `Carbon\Carbon`, `string`
371-
or `integer`.
372-
373-
This method will allow you to dynamically specify the TTL depending on the code being executed.
374-
375-
For example:
376-
377-
```php
378-
use DragonCode\Cache\Services\Cache;
379-
use DragonCode\Contracts\Cache\Ttl;
380-
381-
class Foo implements Ttl
382-
{
383-
protected $value;
384-
385-
public function __construct(string $value)
386-
{
387-
$this->value = $value;
388-
}
389-
390-
public function cacheTtl(): int
391-
{
392-
return $this->value === 'foo' ? 123 : 456;
393-
}
394-
}
395-
396-
Cache::make()->ttl(new Foo('foo'));
397-
// TTL is 7380 seconds
398-
399-
Cache::make()->ttl(new Foo('bar'));
400-
// TTL is 27360 seconds
401-
402-
Cache::make()->ttl(new Foo('foo'), false);
403-
// TTL is 123 seconds
404-
405-
Cache::make()->ttl(new Foo('bar'), false);
406-
// TTL is 456 seconds
407-
```
408-
409368
#### Tagged
410369

411370
For repositories that support tagging, the keys will be saved separated by tags.

0 commit comments

Comments
 (0)