annotate core/lib/Drupal/Component/FileCache/FileCacheInterface.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 4c8ae668cc8c
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\Component\FileCache;
Chris@0 4
Chris@0 5 /**
Chris@0 6 * Interface for objects that allow caching file data.
Chris@0 7 *
Chris@0 8 * Parsing YAML, annotations or similar data out of files can be a
Chris@0 9 * time-consuming process, especially since those files usually don't change
Chris@0 10 * and identical data is parsed over and over again.
Chris@0 11 *
Chris@0 12 * File cache is a self-contained caching layer for such processing, that relies
Chris@0 13 * on the file modification to ensure that cached data is still up to date and
Chris@0 14 * does not need to be invalidated externally.
Chris@0 15 */
Chris@0 16 interface FileCacheInterface {
Chris@0 17
Chris@0 18 /**
Chris@0 19 * Gets data based on a filename.
Chris@0 20 *
Chris@0 21 * @param string $filepath
Chris@0 22 * Path of the file that the cached data is based on.
Chris@0 23 *
Chris@0 24 * @return mixed|null
Chris@0 25 * The data that was persisted with set() or NULL if there is no data
Chris@0 26 * or the file has been modified.
Chris@0 27 */
Chris@0 28 public function get($filepath);
Chris@0 29
Chris@0 30 /**
Chris@0 31 * Gets data based on filenames.
Chris@0 32 *
Chris@0 33 * @param string[] $filepaths
Chris@0 34 * List of file paths used as cache identifiers.
Chris@0 35 *
Chris@0 36 * @return array
Chris@0 37 * List of cached data keyed by the passed in file paths.
Chris@0 38 */
Chris@0 39 public function getMultiple(array $filepaths);
Chris@0 40
Chris@0 41 /**
Chris@0 42 * Stores data based on a filename.
Chris@0 43 *
Chris@0 44 * @param string $filepath
Chris@0 45 * Path of the file that the cached data is based on.
Chris@0 46 * @param mixed $data
Chris@0 47 * The data that should be cached.
Chris@0 48 */
Chris@0 49 public function set($filepath, $data);
Chris@0 50
Chris@0 51 /**
Chris@0 52 * Deletes data from the cache.
Chris@0 53 *
Chris@0 54 * @param string $filepath
Chris@0 55 * Path of the file that the cached data is based on.
Chris@0 56 */
Chris@0 57 public function delete($filepath);
Chris@0 58
Chris@0 59 }