Cache
in package
implements
LoggerAwareInterface
Uses
LoggerAwareTrait
Record Cache
Tags
Interfaces, Classes, Traits and Enums
- LoggerAwareInterface
Table of Contents
- CONTEXT_DEFAULT = 'Default'
- CONTEXT_DISABLED = ''
- CONTEXT_FAVORITE = 'Favorite'
- $cachableSources : array<string|int, mixed>
- Record sources which may be cached.
- $cacheConfig : Config
- $recordFactoryManager : PluginManager
- $recordService : RecordServiceInterface
- __construct() : mixed
- Constructor
- createOrUpdate() : void
- Create a new or update an existing cache entry
- isCachable() : bool
- Check whether a record source is cacheable
- isFallback() : bool
- Convenience method for checking if cache is used as fallback data source
- isPrimary() : bool
- Convenience method for checking if cache is used as primary data data source
- lookup() : array<string|int, mixed>
- Given a record ID, look up a record for that source.
- lookupBatch() : array<string|int, mixed>
- Given an array of IDs and a record source, look up a batch of records for that source.
- setContext() : void
- Set the context for controlling cache behaviour
- debug() : void
- Log a debug message.
- getVuFindRecord() : AbstractBase
- Helper function to get records from cached source-specific record data
- log() : void
- Send a message to the logger.
- logError() : void
- Log an error message.
- logWarning() : void
- Log a warning message.
Constants
CONTEXT_DEFAULT
public
mixed
CONTEXT_DEFAULT
= 'Default'
CONTEXT_DISABLED
public
mixed
CONTEXT_DISABLED
= ''
CONTEXT_FAVORITE
public
mixed
CONTEXT_FAVORITE
= 'Favorite'
Properties
$cachableSources
Record sources which may be cached.
protected
array<string|int, mixed>
$cachableSources
= []
$cacheConfig
protected
Config
$cacheConfig
$recordFactoryManager
protected
PluginManager
$recordFactoryManager
$recordService
protected
RecordServiceInterface
$recordService
Methods
__construct()
Constructor
public
__construct(PluginManager $recordFactoryManager, Config $cacheConfig, RecordServiceInterface $recordService) : mixed
Parameters
- $recordFactoryManager : PluginManager
-
Record driver plugin manager
- $cacheConfig : Config
-
RecordCache.ini contents
- $recordService : RecordServiceInterface
-
Record database service
Return values
mixed —createOrUpdate()
Create a new or update an existing cache entry
public
createOrUpdate(string $recordId, string $source, mixed $rawData) : void
Parameters
- $recordId : string
-
Record id
- $source : string
-
Source name
- $rawData : mixed
-
Raw data from source (must be serializable)
Return values
void —isCachable()
Check whether a record source is cacheable
public
isCachable(string $source) : bool
Parameters
- $source : string
-
Record source
Return values
bool —isFallback()
Convenience method for checking if cache is used as fallback data source
public
isFallback(string $source) : bool
Parameters
- $source : string
-
Record source
Return values
bool —isPrimary()
Convenience method for checking if cache is used as primary data data source
public
isPrimary(string $source) : bool
Parameters
- $source : string
-
Record source
Return values
bool —lookup()
Given a record ID, look up a record for that source.
public
lookup(string $id, string $source) : array<string|int, mixed>
Parameters
- $id : string
-
Record ID
- $source : string
-
Record source
Return values
array<string|int, mixed> —Array of \VuFind\RecordDriver\AbstractBase
lookupBatch()
Given an array of IDs and a record source, look up a batch of records for that source.
public
lookupBatch(array<string|int, mixed> $ids, string $source) : array<string|int, mixed>
Parameters
- $ids : array<string|int, mixed>
-
Record IDs
- $source : string
-
Record source
Return values
array<string|int, mixed> —Array of \VuFind\RecordDriver\AbstractBase
setContext()
Set the context for controlling cache behaviour
public
setContext(string $context) : void
Parameters
- $context : string
-
Cache context
Return values
void —debug()
Log a debug message.
protected
debug(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
- $msg : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = true
-
Prepend class name to message?
Return values
void —getVuFindRecord()
Helper function to get records from cached source-specific record data
protected
getVuFindRecord(RecordEntityInterface $cachedRecord) : AbstractBase
Parameters
- $cachedRecord : RecordEntityInterface
-
Record data
Return values
AbstractBase —log()
Send a message to the logger.
protected
log(string $level, string $message[, array<string|int, mixed> $context = [] ][, bool $prependClass = false ]) : void
Parameters
- $level : string
-
Log level
- $message : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = false
-
Prepend class name to message?
Return values
void —logError()
Log an error message.
protected
logError(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
- $msg : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = true
-
Prepend class name to message?
Return values
void —logWarning()
Log a warning message.
protected
logWarning(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
- $msg : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = true
-
Prepend class name to message?