The
cache
function may be used to get values from the cache. If the given key does not exist in the cache, an optional default value will be returned:<?php $value = cache('key');
$value = cache('key', 'default');
<?php $app['cache'] = $cache = m::mock(stdClass::class);
$this->assertInstanceOf(stdClass::class, cache());
$cache->shouldReceive('put')->once()->with('foo', 'bar', 1);
<?php $cache->shouldReceive('put')->once()->with('foo', 'bar', 1);
cache(['foo' => 'bar'], 1);
$cache->shouldReceive('get')->once()->with('foo')->andReturn('bar');
<?php $cache->shouldReceive('get')->once()->with('foo')->andReturn('bar');
$this->assertSame('bar', cache('foo'));
$cache->shouldReceive('get')->once()->with('foo', null)->andReturn('bar');
<?php $cache->shouldReceive('get')->once()->with('foo', null)->andReturn('bar');
$this->assertSame('bar', cache('foo', null));
$cache->shouldReceive('get')->once()->with('baz', 'default')->andReturn('default');
<?php $cache->shouldReceive('get')->once()->with('baz', 'default')->andReturn('default');
$this->assertSame('default', cache('baz', 'default'));
}
public function testMixDoesNotIncludeHost()
<?php Manager::runAll();
$this->assertTrue(cache()->has('permissions-update-successful'));
$this->assertFalse(cache()->has('trees-update-successful'));
$this->assertTrue(cache()->has('taxonomies-update-successful'));
}
<?php Manager::runAll();
$this->assertTrue(cache()->has('permissions-update-successful'));
$this->assertFalse(cache()->has('trees-update-successful'));
$this->assertTrue(cache()->has('taxonomies-update-successful'));
}
<?php $this->assertTrue(cache()->has('permissions-update-successful'));
$this->assertFalse(cache()->has('trees-update-successful'));
$this->assertTrue(cache()->has('taxonomies-update-successful'));
}
<?php Manager::runAll();
$this->assertFalse(cache()->has('permissions-update-successful'));
$this->assertFalse(cache()->has('trees-update-successful'));
$this->assertFalse(cache()->has('taxonomies-update-successful'));
$this->assertFalse(cache()->has('seo-pro-update-successful'));
<?php Manager::runAll();
$this->assertFalse(cache()->has('permissions-update-successful'));
$this->assertFalse(cache()->has('trees-update-successful'));
$this->assertFalse(cache()->has('taxonomies-update-successful'));
$this->assertFalse(cache()->has('seo-pro-update-successful'));
}
<?php $this->assertFalse(cache()->has('permissions-update-successful'));
$this->assertFalse(cache()->has('trees-update-successful'));
$this->assertFalse(cache()->has('taxonomies-update-successful'));
$this->assertFalse(cache()->has('seo-pro-update-successful'));
}
<?php $this->assertFalse(cache()->has('permissions-update-successful'));
$this->assertFalse(cache()->has('trees-update-successful'));
$this->assertFalse(cache()->has('taxonomies-update-successful'));
$this->assertFalse(cache()->has('seo-pro-update-successful'));
}
<?php Manager::runAll();
$this->assertFalse(cache()->has('permissions-update-successful'));
$this->assertFalse(cache()->has('trees-update-successful'));
$this->assertFalse(cache()->has('taxonomies-update-successful'));
$this->assertFalse(cache()->has('seo-pro-update-successful'));
<?php Manager::runAll();
$this->assertFalse(cache()->has('permissions-update-successful'));
$this->assertFalse(cache()->has('trees-update-successful'));
$this->assertFalse(cache()->has('taxonomies-update-successful'));
$this->assertFalse(cache()->has('seo-pro-update-successful'));
}
<?php $this->assertFalse(cache()->has('permissions-update-successful'));
$this->assertFalse(cache()->has('trees-update-successful'));
$this->assertFalse(cache()->has('taxonomies-update-successful'));
$this->assertFalse(cache()->has('seo-pro-update-successful'));
}