PHP code example of mvaliolahi / cache-sync

1. Go to this page and download the library: Download mvaliolahi/cache-sync library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mvaliolahi / cache-sync example snippets

            
    $cacheSync = new CacheSync(ArrayDriver::class);

        $data = [
            'name' => 'Meysam Valiolahi',
            'email' => '[email protected]',
        ];

        $updatedData = $this->cacheSync
            ->data($data)
            ->change('name', 'Sohrab Valiolahi')
            ->change('email', '[email protected]')
            ->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');