forked from vufind-org/vufind
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'subhh-local' of github.com:subhh/vufind into subhh-local
- Loading branch information
Showing
9 changed files
with
111 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
module/VuFind/src/VuFind/Record/Cache/RecordCacheDbStrategy.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace VuFind\Record\Cache; | ||
|
||
use VuFind\Db\Table\Record; | ||
|
||
final class RecordCacheDbStrategy implements RecordCacheStrategyInterface | ||
{ | ||
/** @var Record */ | ||
private $recordTable; | ||
|
||
public function __construct (Record $recordTable) | ||
{ | ||
$this->recordTable = $recordTable; | ||
} | ||
|
||
public function update (string $recordId, RecordCacheEntry $record) : void | ||
{ | ||
$this->recordTable->updateRecord($recordId, $record->source, $record->data); | ||
} | ||
|
||
public function get (string $recordId, string $source) : ?RecordCacheEntry | ||
{ | ||
if ($record = $this->recordTable->findRecord($recordId, $source)) { | ||
return new RecordCacheEntry($record['source'], $record['data']); | ||
} | ||
return null; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
module/VuFind/src/VuFind/Record/Cache/RecordCacheDbStrategyFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace VuFind\Record\Cache; | ||
|
||
use Interop\Container\ContainerInterface; | ||
|
||
use Laminas\ServiceManager\Factory\FactoryInterface; | ||
|
||
final class RecordCacheDbStrategyFactory implements FactoryInterface | ||
{ | ||
public function __invoke( | ||
ContainerInterface $container, | ||
$requestedName, | ||
array $options = null | ||
) { | ||
if (!empty($options)) { | ||
throw new \Exception('Unexpected options passed to factory.'); | ||
} | ||
|
||
$table = $container->get(\VuFind\Db\Table\PluginManager::class)->get('Record'); | ||
return new RecordCacheDbStrategy($table); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
module/VuFind/src/VuFind/Record/Cache/RecordCacheEntry.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace VuFind\Record\Cache; | ||
|
||
final class RecordCacheEntry | ||
{ | ||
/** @var string */ | ||
public $source; | ||
|
||
/** @var mixed */ | ||
public $data; | ||
|
||
/** @param mixed[] $data */ | ||
public function __construct (string $source, $data) | ||
{ | ||
$this->source = $source; | ||
$this->data = $data; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
module/VuFind/src/VuFind/Record/Cache/RecordCacheStrategyInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace VuFind\Record\Cache; | ||
|
||
interface RecordCacheStrategyInterface | ||
{ | ||
public function update (string $recordId, RecordCacheEntry $record) : void; | ||
public function get (string $recordId, string $source) : ?RecordCacheEntry; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters