Menu

## SourceCache
in package
implements DefinitionSource, MutableDefinitionSource

SourceCache.php : 16

Decorator that caches another definition source.

##### Tags

author

  Matthieu Napoli matthieu@mnapoli.fr

### Table of Contents

#### Interfaces

DefinitionSource
  Source of definitions for entries of the container.
MutableDefinitionSource
  Describes a definition source to which we can add new definitions.

#### Constants

CACHE_KEY = 'php-di.definitions.'

#### Properties

$cachedSource : DefinitionSource
$cacheNamespace : string

#### Methods

__construct() : mixed
addDefinition() : void
getCacheKey() : string
getDefinition() : Definition|null
  Returns the DI definition for the entry name.
getDefinitions() : array<string, Definition>
  Used only for the compilation so we can skip the cache safely.
isSupported() : bool
shouldBeCached() : bool

### Constants

#### CACHE_KEY

SourceCache.php : 18
`public mixed CACHE_KEY = 'php-di.definitions.'`

### Properties

#### $cachedSource

SourceCache.php : 21
`private DefinitionSource $cachedSource`

#### $cacheNamespace

SourceCache.php : 22
`private string $cacheNamespace = ''`

### Methods

#### __construct()

SourceCache.php : 20
`public __construct(DefinitionSource $cachedSource[, string $cacheNamespace = '' ]) : mixed`

##### Parameters

$cachedSource : DefinitionSource
$cacheNamespace : string = ''

#### addDefinition()

SourceCache.php : 62
`public addDefinition(Definition $definition) : void`

##### Parameters

$definition : Definition

#### getCacheKey()

SourceCache.php : 57
`public getCacheKey(string $name) : string`

##### Parameters

$name : string

##### Return values

string

#### getDefinition()

SourceCache.php : 26

Returns the DI definition for the entry name.

`public getDefinition(string $name) : Definition|null`

##### Parameters

$name : string

##### Return values

Definition|null

#### getDefinitions()

SourceCache.php : 45

Used only for the compilation so we can skip the cache safely.

`public getDefinitions() : array<string, Definition>`

##### Return values

array<string, Definition> —

Definitions indexed by their name.

#### isSupported()

SourceCache.php : 50
`public static isSupported() : bool`

##### Return values

bool

#### shouldBeCached()

SourceCache.php : 67
`private shouldBeCached([Definition|null $definition = null ]) : bool`

##### Parameters

$definition : Definition|null = null

##### Return values

bool

## Search results