Skip to content

Commit

Permalink
Avoid call to method alias
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Aug 18, 2019
1 parent c1c8be6 commit be140fc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Cache/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function put($key, $value, $ttl = null)
$seconds = $this->getSeconds($ttl);

if ($seconds <= 0) {
return $this->delete($key);
return $this->forget($key);
}

$result = $this->store->put($this->itemKey($key), $value, $seconds);
Expand Down

5 comments on commit be140fc

@gocanto
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GrahamCampbell cool.

any particular reason why this is better? - I am always on the favor of these changes, but I do not have arguments.

@antonkomarev
Copy link
Contributor

@antonkomarev antonkomarev commented on be140fc Aug 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Alias might not exist in interfaces.
  2. Alias will be obviously slower because of +1 method call.
  3. Alias might be removed in future releases (alias might be a legacy code and not removed instantly to not introduce breaking changes).

@GrahamCampbell
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alias might not exist in interfaces.

The alias does exist in the interface actually in this case.

Alias might be removed in future releases

Nope. It is unlikely to be. forget is the laravel contract, and delete is the psr contract. ;)

@GrahamCampbell
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alias will be obviously slower because of +1 method call.

Yes, this was the only reason.

@gocanto
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks you guys! :)

Please sign in to comment.