MongolidLaravel\LaravelCacheComponent::has PHP Method

has() public method

Determine if an item exists in the cache. This method will also check if the ttl of the given cache key has been expired and will free the memory if so.
public has ( string $key ) : boolean
$key string Cache key of the item.
return boolean Has cache key.
    public function has(string $key) : bool
    {
        return $this->laravelCache->has($key);
    }

Usage Example

コード例 #1
0
 public function testShouldCheckIfHave()
 {
     // Set
     $cacheRepo = m::mock(Repository::class);
     $serializer = m::mock(Serializer::class);
     $component = new LaravelCacheComponent($cacheRepo, $serializer);
     $key = 'foo';
     $exists = true;
     // Expectations
     $cacheRepo->shouldReceive('has')->once()->with($key)->andReturn($exists);
     // Assertion
     $this->assertEquals($exists, $component->has($key));
 }
LaravelCacheComponent