Drupal 8  8.0.2
CachedStorage Class Reference
Inheritance diagram for CachedStorage:

Public Member Functions

 __construct (StorageInterface $storage, CacheBackendInterface $cache)
 
 exists ($name)
 
 read ($name)
 
 readMultiple (array $names)
 
 write ($name, array $data)
 
 delete ($name)
 
 rename ($name, $new_name)
 
 encode ($data)
 
 decode ($raw)
 
 listAll ($prefix= '')
 
 deleteAll ($prefix= '')
 
 resetListCache ()
 
 createCollection ($collection)
 
 getAllCollectionNames ()
 
 getCollectionName ()
 

Protected Member Functions

 findByPrefix ($prefix)
 
 getCacheKey ($name)
 
 getCacheKeys (array $names)
 
 getCollectionPrefix ()
 

Protected Attributes

 $storage
 
 $cache
 
 $findByPrefixCache = array()
 

Additional Inherited Members

- Data Fields inherited from StorageInterface
const DEFAULT_COLLECTION = ''
 

Detailed Description

Defines the cached storage.

The class gets another storage and a cache backend injected. It reads from the cache and delegates the read to the storage on a cache miss. It also handles cache invalidation.

Constructor & Destructor Documentation

__construct ( StorageInterface  $storage,
CacheBackendInterface  $cache 
)

Constructs a new CachedStorage.

Parameters
\Drupal\Core\Config\StorageInterface$storageA configuration storage to be cached.
\Drupal\Core\Cache\CacheBackendInterface$cacheA cache backend used to store configuration.

References Drupal\cache().

Here is the call graph for this function:

Member Function Documentation

createCollection (   $collection)

{Creates a collection on the storage.A configuration storage can contain multiple sets of configuration objects in partitioned collections. The collection name identifies the current collection used.Implementations of this method must provide a new instance to avoid side effects caused by the fact that Config objects have their storage injected.

Parameters
string$collectionThe collection name. Valid collection names conform to the following regex [a-zA-Z_.]. A storage does not need to have a collection set. However, if a collection is set, then storage should use it to store configuration in a way that allows retrieval of configuration for a particular collection.
Returns
A new instance of the storage backend with the collection set.
}

Implements StorageInterface.

decode (   $raw)

{Decodes configuration data from the storage-specific format.

Parameters
string$rawThe raw configuration data string to decode.
Returns
array The decoded configuration data as an associative array.

This is a publicly accessible static method to allow for alternative usages in data conversion scripts and also tests.}

Implements StorageInterface.

delete (   $name)

{Deletes a configuration object from the storage.

Parameters
string$nameThe name of a configuration object to delete.
Returns
bool TRUE on success, FALSE otherwise.
}

Implements StorageInterface.

References Drupal\cache(), and CachedStorage\getCacheKey().

Here is the call graph for this function:

deleteAll (   $prefix = '')

{Deletes configuration objects whose names start with a given prefix.Given the following configuration object names:

  • node.type.article
  • node.type.page
Passing the prefix 'node.type.' will delete the above configuration objects.
Parameters
string$prefix(optional) The prefix to search for. If omitted, all configuration objects that exist will be deleted.
Returns
bool TRUE on success, FALSE otherwise.
}

Implements StorageInterface.

References Drupal\cache(), and CachedStorage\getCacheKeys().

Here is the call graph for this function:

encode (   $data)

{Encodes configuration data into the storage-specific format.

Parameters
array$dataThe configuration data to encode.
Returns
string The encoded configuration data.

This is a publicly accessible static method to allow for alternative usages in data conversion scripts and also tests.}

Implements StorageInterface.

exists (   $name)

{Returns whether a configuration object exists.

Parameters
string$nameThe name of a configuration object to test.
Returns
bool TRUE if the configuration object exists, FALSE otherwise.
}

Implements StorageInterface.

findByPrefix (   $prefix)
protected

Finds configuration object names starting with a given prefix.

Given the following configuration objects:

  • node.type.article
  • node.type.page

Passing the prefix 'node.type.' will return an array containing the above names.

Parameters
string$prefixThe prefix to search for
Returns
array An array containing matching configuration object names.

References CachedStorage\getCacheKey().

Referenced by CachedStorage\listAll().

Here is the call graph for this function:

Here is the caller graph for this function:

getAllCollectionNames ( )

{Gets the existing collections.A configuration storage can contain multiple sets of configuration objects in partitioned collections. The collection key name identifies the current collection used.

Returns
array An array of existing collection names.
}

Implements StorageInterface.

getCacheKey (   $name)
protected

Returns a cache key for a configuration name using the collection.

Parameters
string$nameThe configuration name.
Returns
string The cache key for the configuration name.

References CachedStorage\getCollectionPrefix().

Referenced by CachedStorage\delete(), CachedStorage\findByPrefix(), CachedStorage\read(), CachedStorage\rename(), and CachedStorage\write().

Here is the call graph for this function:

Here is the caller graph for this function:

getCacheKeys ( array  $names)
protected

Returns a cache key map for an array of configuration names.

Parameters
array$namesThe configuration names.
Returns
array An array of cache keys keyed by configuration names.

References CachedStorage\getCollectionPrefix().

Referenced by CachedStorage\deleteAll(), and CachedStorage\readMultiple().

Here is the call graph for this function:

Here is the caller graph for this function:

getCollectionName ( )

{Gets the name of the current collection the storage is using.

Returns
string The current collection name.
}

Implements StorageInterface.

getCollectionPrefix ( )
protected

Returns a cache ID prefix to use for the collection.

Returns
string The cache ID prefix.

References StorageInterface\DEFAULT_COLLECTION.

Referenced by CachedStorage\getCacheKey(), and CachedStorage\getCacheKeys().

Here is the caller graph for this function:

listAll (   $prefix = '')

{Gets configuration object names starting with a given prefix.Given the following configuration objects:

  • node.type.article
  • node.type.page
Passing the prefix 'node.type.' will return an array containing the above names.
Parameters
string$prefix(optional) The prefix to search for. If omitted, all configuration object names that exist are returned.
Returns
array An array containing matching configuration object names.
}

Implements StorageInterface.

References CachedStorage\findByPrefix().

Here is the call graph for this function:

read (   $name)

{Reads configuration data from the storage.

Parameters
string$nameThe name of a configuration object to load.
Returns
array|bool The configuration data stored for the configuration object name. If no configuration data exists for the given name, FALSE is returned.
}

Implements StorageInterface.

References Drupal\cache(), and CachedStorage\getCacheKey().

Here is the call graph for this function:

readMultiple ( array  $names)

{Reads configuration data from the storage.

Parameters
array$namesList of names of the configuration objects to load.
Returns
array A list of the configuration data stored for the configuration object name that could be loaded for the passed list of names.
}

Implements StorageInterface.

References Drupal\cache(), and CachedStorage\getCacheKeys().

Here is the call graph for this function:

rename (   $name,
  $new_name 
)

{Renames a configuration object in the storage.

Parameters
string$nameThe name of a configuration object to rename.
string$new_nameThe new name of a configuration object.
Returns
bool TRUE on success, FALSE otherwise.
}

Implements StorageInterface.

References Drupal\cache(), and CachedStorage\getCacheKey().

Here is the call graph for this function:

resetListCache ( )

Clears the static list cache.

Implements StorageCacheInterface.

write (   $name,
array  $data 
)

{Writes configuration data to the storage.

Parameters
string$nameThe name of a configuration object to save.
array$dataThe configuration data to write.
Returns
bool TRUE on success, FALSE in case of an error.
Exceptions
\Drupal\Core\Config\StorageExceptionIf the back-end storage does not exist and cannot be created.
}

Implements StorageInterface.

References Drupal\cache(), and CachedStorage\getCacheKey().

Here is the call graph for this function:


The documentation for this class was generated from the following file: