Skip to content

The ReadWriteAdapter allows to use one adapter instance for reading and one for writing. Part of the https://github.com/php-cmsig/search project. READ-ONLY Repository

License

Notifications You must be signed in to change notification settings

PHP-CMSIG/seal-read-write-adapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2c4b429 · Feb 25, 2025

History

66 Commits
Feb 23, 2023
Nov 16, 2024
Apr 30, 2023
Apr 30, 2023
Jan 9, 2024
Mar 26, 2023
Dec 28, 2022
Dec 11, 2024
Feb 25, 2025
Feb 25, 2025
Mar 18, 2024
Nov 16, 2024

Repository files navigation

Note: This is part of the cmsig/search project create issues in the main repository.


SEAL Logo with an abstract seal sitting on a telescope.
Logo created by Meine Wilma

SEAL
Read Write Adapter



The ReadWriteAdapter allows to use one adapter instance for reading and one for writing. This is useful if you want to reindex something without a downtime.

Note: This project is heavily under development and any feedback is greatly appreciated.

Installation

Use composer for install the package:

composer require cmsig/seal cmsig/seal-read-write-adapter

Usage

To use the adapter an instance of ReadWriteAdapter need to be created which get a $readAdapter and $writeAdapter which are instances of the AdapterInterface.

The following code shows how to create an Engine using this Adapter:

<?php

use CmsIg\Seal\Adapter\Elasticsearch\ElasticsearchAdapter;
use CmsIg\Seal\Adapter\ReadWrite\ReadWriteAdapter;
use CmsIg\Seal\Engine;

$readAdapter = new ElasticsearchAdapter(/* .. */); // can be any adapter
$writeAdapter = new ElasticsearchAdapter(/* .. */); // can be any adapter

$engine = new Engine(
    new ReadWriteAdapter(
        $readAdapter,
        $writeAdapter
    ),
    $schema,
);

Via DSN for your favorite framework:

multi://readAdapter?adapters[]=writeAdapter
read-write://readAdapter?write=multiAdapter

Note Read a document and partial update it based on the read document should be avoided when using this adapter, as the read document could already be outdated. So always fully update the document and never do based on read documents. Have a look at the MultiAdapter to write into read and write adapter.

Authors