mvaliolahi / cache-sync
PHP缓存同步库。
v0.0.1
2019-12-09 13:20 UTC
Requires (Dev)
- phpunit/phpunit: 6.2
This package is auto-updated.
Last update: 2024-09-10 00:15:51 UTC
README
使用优雅的语法同步缓存数据!
安装
composer require mvaliolahi/cache-sync
设置
$cacheSync = new CacheSync(ArrayDriver::class);
- 注意:ArrayDriver可以用'Mvaliolahi\CacheSync\Contracts\CacheSyncDriver'接口的任何实现来替换。
更新数组内部的单个键
$data = [ 'name' => 'Meysam Valiolahi', 'email' => 'mvaliolahi@gmail.com', ]; $updatedData = $this->cacheSync ->data($data) ->change('name', 'Sohrab Valiolahi') ->change('email', 'sohrab_valiolahi@gmail.com') ->get()
更新数组内部的嵌套键
$data = [ 'data' => [ 'houses' => [ [ 'id' => 101, 'location' => 'Dubai' ], [ 'id' => 102, 'location' => 'Germany' ] ] ] ]; $this->cacheSync ->data($data) ->change('data.houses@id=101', [ 'location' => 'Iran' ]) ->get()
持久化更改
$cacheSync->persistTo('users:user.1');