This project includes a PHP script that transfers tables and data from a MySQL database to a Redis database. This script allows you to fetch data from MySQL and write it to Redis. 🛠️
Ensure that the following software is installed on your system:
- PHP 7.x or higher 🐘
- MySQL 5.x or higher 🗄️
- Redis 5.x or higher 🔄
git clone https://github.com/enesbabekoglu/MySQL-To-Redis-PHP.git
cd MySQL-To-Redis-PHPphp transfer.phpIf your MySQL table contains data that is updated periodically and you want to transfer these updates to your Redis database at regular intervals, you can set up a cron job to automate this process. Here’s how to do it step by step:
crontab -e*/30 * * * * /usr/bin/php /path/to/your/script/transfer.phpThis cron job will run the transfer.php script every 30 minutes.
*/30 * * * *: Specifies that it should run every 30 minutes. ⏰/usr/bin/php: The full path to the PHP executable. Adjust this path if PHP is located elsewhere on your system. 📍/path/to/your/script/transfer.php: The full path to yourtransfer.phpscript. Update this to match the actual location of your script. 📂
If your transfer.php file is located in the /var/www/html directory and your PHP executable is at /usr/bin/php, the cron job line would be:
*/30 * * * * /usr/bin/php /var/www/html/transfer.phpAfter adding this line to your crontab file, save the changes and exit. The transfer.php script will now run automatically every 30 minutes.
To verify that the cron job has been set up correctly, you can list the current cron jobs with the following command:
crontab -lThis project is licensed under the MIT License. For more details, please refer to the LICENSE file.
Bu proje, MySQL veritabanındaki tablo ve verileri Redis veritabanına aktaran bir PHP scripti içerir. Bu script, MySQL'den veri çekip Redis'e yazmanızı sağlar. 🛠️
Aşağıdaki yazılımların sisteminizde kurulu olması gerekmektedir:
- PHP 7.x veya üstü 🐘
- MySQL 5.x veya üstü 🗄️
- Redis 5.x veya üstü 🔄
git clone https://github.com/enesbabekoglu/MySQL-To-Redis-PHP.git
cd MySQL-To-Redis-PHPphp transfer.phpEğer MySQL tablonuzda belirli aralıklarla güncellenen veriler bulunuyorsa ve bu güncel verileri Redis veritabanınıza düzenli aralıklarla aktarmak istiyorsanız, bir cronjob ayarlayarak bu işlemi otomatikleştirebilirsiniz. İşte adım adım yapacaklarınız:
crontab -e*/30 * * * * /usr/bin/php /path/to/your/script/transfer.phpBu cronjob, transfer.php dosyasını her 30 dakikada bir çalıştıracaktır.
*/30 * * * *: Her 30 dakikada bir çalıştırılacağını belirtir. ⏰/usr/bin/php: PHP çalıştırıcısının tam yoludur. PHP'nin yeri farklıysa, doğru yolu kullanmalısınız. 📍/path/to/your/script/transfer.php:transfer.phpdosyasının tam yoludur. Bu yolu kendi dosya konumunuza göre ayarlamalısınız. 📂
Eğer transfer.php dosyanız /var/www/html dizininde bulunuyorsa ve PHP çalıştırıcınız /usr/bin/php konumundaysa, cronjob satırınız şu şekilde olacaktır:
*/30 * * * * /usr/bin/php /var/www/html/transfer.phpBu satırı crontab dosyasına ekledikten sonra, değişiklikleri kaydedin ve çıkın. Artık transfer.php dosyanız her 30 dakikada bir otomatik olarak çalıştırılacaktır.
Cronjob'un doğru şekilde ayarlandığını kontrol etmek için mevcut cronjob'ları listelemek adına şu komutu kullanabilirsiniz:
crontab -lBu proje MIT Lisansı ile lisanslanmıştır. Daha fazla bilgi için LICENSE dosyasına bakabilirsiniz.


