drinky08 / cache-evaluator
PHP class to determine whether or not a cache is fresh.
Installs: 3 019
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=5.4.0
- beberlei/assert: @stable
Requires (Dev)
- phpunit/phpunit: 5.0.*
This package is not auto-updated.
Last update: 2020-10-28 06:15:24 UTC
README
PHP class to determine whether or not a cache is fresh.
Usage
$cacheFresh = \CacheEvaluator\Evaluate\SingleRecord::fromArray((array) $data, (array) $record) ->addFieldToMatch((string) $field1) ->addFieldToCheck((string) $field2) ->evaluate() ->isCacheFresh();
$cacheFresh = \CacheEvaluator\Evaluate\MultipleRecords::fromArray((array) $data, (array) $records) ->addFieldToMatch((string) $field1) ->addFieldToCheck((string) $field2) ->evaluate() ->isCacheFresh();
$recordsDifferentInCache = \CacheEvaluator\Evaluate\MultipleRecords::fromArray((array) $data, (array) $records) ->addFieldToMatch((string) $field1) ->addFieldToCheck((string) $field2) ->evaluate() ->getRecordsDifferentInCache();
CacheEvaluator expects the following format for inputs:
- Existing cache data is expected in the folowing format:
[0 => ['col1' => 'blah', 'col2' => 'blah'], 1 =>['col1' => 'blah', 'col2' => 'blah']]
- Existing record is expected in the following format for
SingleRecord
:['col1' => 'blah', 'col2' => 'blah']
- Existing records is expected in the following format for
MultipleRecords
:[['col1' => 'blah', 'col2' => 'blah'],['col1' => 'foo', 'col2' => 'bah']]
- Fields to match and fields to check is expected in the following format:
['col1', 'col2']