LdapTools\Cache\CacheInterface::set PHP Method

set() public method

Cache an item.
public set ( LdapTools\Cache\CacheableItemInterface $item )
$item LdapTools\Cache\CacheableItemInterface
    public function set(CacheableItemInterface $item);

Usage Example

 function it_should_not_call_the_load_schema_event_when_retrieving_from_the_cache(CacheInterface $cache, SchemaParserInterface $parser, $dispatcher)
 {
     $cache->getUseAutoCache()->willReturn(true);
     $cache->contains(LdapObjectSchema::getCacheType(), 'ad.user')->willReturn(true);
     $cache->getCacheCreationTime(LdapObjectSchema::getCacheType(), 'ad.user')->willReturn(new \DateTime('2015-1-3'));
     $cache->set(Argument::any())->shouldNotBeCalled();
     $cache->get(LdapObjectSchema::getCacheType(), 'ad.user')->willReturn(new LdapObjectSchema('ad', 'user'));
     $parser->parse('ad', 'user')->shouldNotBeCalled();
     $parser->getSchemaModificationTime('ad')->willReturn(new \DateTime('2015-1-2'));
     new LdapObjectSchemaEvent(Event::LDAP_SCHEMA_LOAD, new LdapObjectSchema('ad', 'user'));
     $dispatcher->dispatch(Argument::type('\\LdapTools\\Event\\LdapObjectSchemaEvent'))->shouldNotBeCalled();
     $this->beConstructedWith($cache, $parser, $dispatcher);
     $this->get('ad', LdapObjectType::USER);
 }