Skip to content

Commit

Permalink
[6.x] Allow cache helper to have an optional expiration parameter (sy…
Browse files Browse the repository at this point in the history
…ntactic sugar for forever) (#31554)

* Allow cache forever usage with helper

* No longer needed
  • Loading branch information
lancepioch authored Feb 24, 2020
1 parent 61b5aa1 commit 6ad1b81
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
8 changes: 1 addition & 7 deletions src/Illuminate/Foundation/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,7 @@ function cache()
);
}

if (! isset($arguments[1])) {
throw new Exception(
'You must specify an expiration time when setting a value in the cache.'
);
}

return app('cache')->put(key($arguments[0]), reset($arguments[0]), $arguments[1]);
return app('cache')->put(key($arguments[0]), reset($arguments[0]), $arguments[1] ?? null);
}
}

Expand Down
8 changes: 0 additions & 8 deletions tests/Foundation/FoundationHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ public function testCache()
$this->assertSame('default', cache('baz', 'default'));
}

public function testCacheThrowsAnExceptionIfAnExpirationIsNotProvided()
{
$this->expectException(Exception::class);
$this->expectExceptionMessage('You must specify an expiration time when setting a value in the cache.');

cache(['foo' => 'bar']);
}

public function testUnversionedElixir()
{
$file = 'unversioned.css';
Expand Down

0 comments on commit 6ad1b81

Please sign in to comment.