MongolidLaravel\LaravelCacheComponent::has PHP 메소드

has() 공개 메소드

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.
리턴 boolean Has cache key.
    public function has(string $key) : bool
    {
        return $this->laravelCache->has($key);
    }

Usage Example

 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