|
string | $area |
| The area this definition is associated with.
|
|
bool | $canuselocalstore = false |
| Whether this cache supports local storages.
|
|
string | $component |
| The component this definition is associated with.
|
|
string | $datasource = null |
| The data source class to use with this definition.
|
|
string | $datasourcefile = null |
| The file in which the data source class exists.
|
|
string | $definitionhash = null |
| A hash identifier of this definition.
|
|
string | $id |
| The identifier for the definition.
|
|
array | $identifiers = null |
| An array of identifiers provided to this cache when it was initialised.
|
|
array | $invalidationevents = array() |
| An array of events that should cause this cache to invalidate.
|
|
array | $keyprefixmulti = null |
| Key prefix to use with cache stores that support multi keys.
|
|
string | $keyprefixsingle = null |
| Key prefix for use with single key cache stores.
|
|
bool | $mappingsonly = false |
| Set to true if this cache should only use mapped cache stores and not the default mode cache store.
|
|
int | $maxsize = null |
| Sets the maximum number of items that can exist in the cache.
|
|
int | $mode |
| The mode for the defintion.
|
|
string | $overrideclass = null |
| The class to use as the cache loader for this definition.
|
|
string | $overrideclassfile = null |
| The file in which the override class exists.
|
|
bool | $requiredataguarantee = false |
| If set to true then only stores that guarantee data may be used with this definition.
|
|
array | $requireidentifiers = array() |
| An array of identifiers that must be provided when the definition is used to create a cache.
|
|
bool | $requirelocking = false |
| If set to true then we know that this definition requires the locking functionality.
|
|
bool | $requirelockingbeforewrite = false |
| Gets set to true if this definition requires a lock to be acquired before a write is attempted.
|
|
bool | $requirelockingread = false |
| Set to true if this definition requires read locking.
|
|
bool | $requirelockingwrite = false |
| Gets set to true if this definition requires write locking.
|
|
bool | $requiremultipleidentifiers = false |
| If set to true then only stores that support multple identifiers may be used with this definition.
|
|
bool | $requiresearchable = false |
| Gets set to true if this definition requires searchable stores.
|
|
int | $selectedsharingoption = self::SHARING_DEFAULT |
| The selected sharing option.
|
|
int | $sharingoptions |
| The selected sharing mode for this definition.
|
|
bool | $simpledata = false |
| Set to true if we know the data is scalar or array of scalar.
|
|
bool | $simplekeys = false |
| If set to true we know the keys are simple.
|
|
bool | $staticacceleration = false |
| Set to true if the cache should hold onto items passing through it to speed up subsequent requests.
|
|
int | $staticaccelerationsize = false |
| The maximum number of items that static acceleration cache should hold onto.
|
|
int | $ttl = 0 |
| The TTL for data in this cache.
|
|
string | $userinputsharingkey = '' |
| The user input key to use if the SHARING_INPUT option has been selected.
|
|
The cache definition class.
Cache definitions need to be defined in db/caches.php files. They can be constructed with the following options.
Required settings:
- mode [int] Sets the mode for the definition. Must be one of cache_store\MODE_*
Optional settings:
- simplekeys [bool] Set to true if your cache will only use simple keys for its items. Simple keys consist of digits, underscores and the 26 chars of the english language. a-zA-Z0-9_ If true the keys won't be hashed before being passed to the cache store for gets/sets/deletes. It will be better for performance and possible only becase we know the keys are safe.
- simpledata [bool] If set to true we know that the data is scalar or array of scalar.
- requireidentifiers [array] An array of identifiers that must be provided to the cache when it is created.
- requiredataguarantee [bool] If set to true then only stores that can guarantee data will remain available once set will be used.
- requiremultipleidentifiers [bool] If set to true then only stores that support multiple identifiers will be used.
- requirelockingread [bool] If set to true then a lock will be gained before reading from the cache store. It is recommended not to use this setting unless 100% absolutely positively required. Remember 99.9% of caches will NOT need this setting. This setting will only be used for application caches presently.
- requirelockingwrite [bool] If set to true then a lock will be gained before writing to the cache store. As above this is not recommended unless truly needed. Please think about the order of your code and deal with race conditions there first. This setting will only be used for application caches presently.
- maxsize [int] If set this will be used as the maximum number of entries within the cache store for this definition. Its important to note that cache stores don't actually have to acknowledge this setting or maintain it as a hard limit.
- overrideclass [string] A class to use as the loader for this cache. This is an advanced setting and will allow the developer of the definition to take 100% control of the caching solution. Any class used here must inherit the cache_loader interface and must extend default cache loader for the mode they are using.
- overrideclassfile [string] Suplements the above setting indicated the file containing the class to be used. This file is included when required.
- datasource [string] A class to use as the data loader for this definition. Any class used here must inherit the cache_data_loader interface.
- datasourcefile [string] Supplements the above setting indicating the file containing the class to be used. This file is included when required.
- staticacceleration The cache loader will keep an array of the items set and retrieved to the cache during the request. Consider using this setting when you know that there are going to be many calls to the cache for the same information. Requests for data in this array will be ultra fast, but it will cost memory.
- staticaccelerationsize [int] This supplements the above setting by limiting the number of items in the static acceleration array. Tweaking this setting lower will allow you to minimise the memory implications above while hopefully still managing to offset calls to the cache store.
- ttl [int] A time to live for the data (in seconds). It is strongly recommended that you don't make use of this and instead try to create an event driven invalidation system. Not all cache stores will support this natively and there are undesired performance impacts if the cache store does not.
- mappingsonly [bool] If set to true only the mapped cache store(s) will be used and the default mode store will not. This is a super advanced setting and should not be used unless absolutely required. It allows you to avoid the default stores for one reason or another.
- invalidationevents [array] An array of events that should cause this cache to invalidate some or all of the items within it.
- sharingoptions [int] The sharing options that are appropriate for this definition. Should be the sum of the possible options.
- defaultsharing [int] The default sharing option to use. It's highly recommended that you don't set this unless there is a very specific reason not to use the system default.
- canuselocalstore [bool] The cache is able to safely run with multiple copies on different webservers without any need for administrator intervention to ensure that data stays in sync across nodes. This is usually managed by a revision system as seen in modinfo cache or language cache. Requiring purge on upgrade is not sufficient as it requires administrator intervention on each node to make it work.
For examples take a look at lib/db/caches.php
- Copyright
- 2012 Sam Hemelryk
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later