mvaliolahi / cache-sync
PHP Cache synchronization library.
v0.0.1
2019-12-09 13:20 UTC
Requires (Dev)
- phpunit/phpunit: 6.2
This package is auto-updated.
Last update: 2024-10-10 00:27:20 UTC
README
synchronize cache data using elegant syntax!
Install
composer require mvaliolahi/cache-sync
Setup
$cacheSync = new CacheSync(ArrayDriver::class);
- note: ArrayDriver can be replaced with any implementation of 'Mvaliolahi\CacheSync\Contracts\CacheSyncDriver'.
Update single key inside array
$data = [ 'name' => 'Meysam Valiolahi', 'email' => 'mvaliolahi@gmail.com', ]; $updatedData = $this->cacheSync ->data($data) ->change('name', 'Sohrab Valiolahi') ->change('email', 'sohrab_valiolahi@gmail.com') ->get()
Update Nested key inside array
$data = [ 'data' => [ 'houses' => [ [ 'id' => 101, 'location' => 'Dubai' ], [ 'id' => 102, 'location' => 'Germany' ] ] ] ]; $this->cacheSync ->data($data) ->change('data.houses@id=101', [ 'location' => 'Iran' ]) ->get()
Persis changes
$cacheSync->persistTo('users:user.1');