Skip to content

Commit

Permalink
Merge pull request #252 from cyrildewit/release/v6.0.2
Browse files Browse the repository at this point in the history
Release v6.0.2
  • Loading branch information
cyrildewit authored Jan 2, 2021
2 parents 5747def + 42994c1 commit 6992944
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to `Eloquent Viewable` will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [v6.0.2]

### Fixed

- Revert breaking change of `remember` method in `Views` contract. The `$lifetime` variable has now a default value of `null`.

## [v6.0.1]

### Fixed
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ protected $removeViewsOnDelete = true;

Caching the views count can be challenging in some scenarios. The period can be for example dynamic which makes caching not possible. That's why you can make use of the in-built caching functionality.

To cache the views count, simply add the `remember()` method to the chain.
To cache the views count, simply add the `remember()` method to the chain. The default lifetime is forever.

Examples:

Expand All @@ -392,12 +392,15 @@ views($post)->period(Period::pastMonths(2))->remember()->count();
views($post)->period(Period::subHours(6))->remember()->count();
```

The default lifetime is configurable through the config file. Alternatively, you can pass a custom lifetime to the `remember` method.

```php
views($post)
->remember(now()->addHours(6))
->count();
// Cache for 3600 seconds
views($post)->remember(3600)->count();

// Cache until the defined DateTime
views($post)->remember(now()->addWeeks(2))->count();

// Cache forever
views($post)->remember()->count();
```

## Optimizing
Expand Down
15 changes: 15 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Table of contents

- [Upgrading from v6.0.1 to v6.0.2](#upgrading-from-v601-to-v602)
- [Upgrading from v5.2.1 to v6.0.0](#upgrading-from-v521-to-v600)
- [Upgrading from v5.2.0 to v5.2.1](#upgrading-from-v520-to-v521)
- [Upgrading from v5.1.0 to v5.2.0](#upgrading-from-v510-to-v520)
Expand All @@ -13,6 +14,14 @@
- [Upgrading from v2.0.0 to v2.1.0](#upgrading-from-v200-to-v210)
- [Upgrading from v1.0.5 to v2.0.0](#upgrading-from-v105-to-v200)

## Upgrading from v6.0.1 to v6.0.2

There are no manual changes needed.

## Upgrading from v6.0.0 to v6.0.1

There are no manual changes needed.

## Upgrading from v5.2.1 to v6.0.0

### Check requirements
Expand Down Expand Up @@ -48,6 +57,12 @@ The parameters of the `orderByViews` query scope in the `Viewable` contract have
+public function scopeOrderByUniqueViews(Builder $query, string $direction = 'desc', ?Period $period = null, ?string $collection = null, string $as = 'unique_views_count'): Builder;
```

### The default cache lifetime has been changed

The default cache lifetime functionality has been removed. The default value is now `null`, which means it will be cached forever.

Look for all occurrences of the `remember` method and pass the desired lifetime.

### Changes to the `Views` contract

* The `$viewable` argument of the `forViewable` method cannot be `null` anymore.
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/Views.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ public function unique(bool $state = true): self;
*
* @param \DateTimeInterface|int|null $lifetime
*/
public function remember($lifetime): self;
public function remember($lifetime = null): self;
}

0 comments on commit 6992944

Please sign in to comment.