|
| 1 | +# PHP Database Cache |
| 2 | + |
| 3 | +[](https://github.com/not-empty/database-cache-php-lib/releases) |
| 4 | +[](https://codecov.io/gh/not-empty/database-cache-php-lib) |
| 5 | +[](https://github.com/not-empty/database-cache-php-lib/actions/workflows/php.yml) |
| 6 | +[](https://packagist.org/packages/kiwfy/database-cache-php) |
| 7 | +[](https://packagist.org/packages/not-empty/database-cache-php-lib) |
| 8 | +[](http://makeapullrequest.com) |
| 9 | +[](https://github.com/not-empty/database-cache-php-lib/blob/master/LICENSE) |
| 10 | + |
| 11 | +PHP library for put all database result in cache |
| 12 | + |
| 13 | +### Installation |
| 14 | + |
| 15 | +[Release 6.0.0](https://github.com/not-empty/database-cache-php-lib/releases/tag/6.0.0) Requires [PHP](https://php.net) 8.2 |
| 16 | + |
| 17 | +[Release 5.0.0](https://github.com/not-empty/database-cache-php-lib/releases/tag/5.0.0) Requires [PHP](https://php.net) 8.1 |
| 18 | + |
| 19 | +[Release 4.0.0](https://github.com/not-empty/database-cache-php-lib/releases/tag/4.0.0) Requires [PHP](https://php.net) 7.4 |
| 20 | + |
| 21 | +[Release 3.0.0](https://github.com/not-empty/database-cache-php-lib/releases/tag/3.0.0) Requires [PHP](https://php.net) 7.3 |
| 22 | + |
| 23 | +[Release 2.0.0](https://github.com/not-empty/database-cache-php-lib/releases/tag/2.0.0) Requires [PHP](https://php.net) 7.2 |
| 24 | + |
| 25 | +[Release 1.0.0](https://github.com/not-empty/database-cache-php-lib/releases/tag/1.0.0) Requires [PHP](https://php.net) 7.1 |
| 26 | + |
| 27 | +The recommended way to install is through [Composer](https://getcomposer.org/). |
| 28 | + |
| 29 | +```sh |
| 30 | +composer require not-empty/database-cache-php-lib |
| 31 | +``` |
| 32 | + |
| 33 | +### Usage |
| 34 | + |
| 35 | +Setting a credential |
| 36 | + |
| 37 | +```php |
| 38 | +use DatabaseCache\Repository; |
| 39 | +$redisConfig = [ |
| 40 | + 'host' => 'localhost', |
| 41 | + 'port' => 6379, |
| 42 | +]; |
| 43 | +$repository = new Repository($redisConfig); |
| 44 | +$data = [ |
| 45 | + 'name' => 'gabriel', |
| 46 | + 'email' => 'testegabs@teste.com', |
| 47 | +]; |
| 48 | +$repository->setQuery( |
| 49 | + 'table:id', |
| 50 | + json_encode($data) |
| 51 | +); |
| 52 | +$getData = $repository->getQuery('table:id'); |
| 53 | +var_dump($data); |
| 54 | +``` |
| 55 | + |
| 56 | +if you want an environment to run or test it, you can build and install dependences like this |
| 57 | + |
| 58 | +```sh |
| 59 | +docker build --build-arg PHP_VERSION=8.2-cli -t not-empty/database-cache-php-lib:php82 -f contrib/Dockerfile . |
| 60 | +``` |
| 61 | + |
| 62 | +Access the container |
| 63 | +```sh |
| 64 | +docker run -v ${PWD}/:/var/www/html -it not-empty/database-cache-php-lib:php82 bash |
| 65 | +``` |
| 66 | + |
| 67 | +Verify if all dependencies is installed |
| 68 | +```sh |
| 69 | +composer install --no-dev --prefer-dist |
| 70 | +``` |
| 71 | + |
| 72 | +and run |
| 73 | +```sh |
| 74 | +php sample/repository-sample.php |
| 75 | +``` |
| 76 | + |
| 77 | +### Development |
| 78 | + |
| 79 | +Want to contribute? Great! |
| 80 | + |
| 81 | +The project using a simple code. |
| 82 | +Make a change in your file and be careful with your updates! |
| 83 | +**Any new code will only be accepted with all validations.** |
| 84 | + |
| 85 | +To ensure that the entire project is fine: |
| 86 | + |
| 87 | +First you need to building a correct environment to install all dependences |
| 88 | + |
| 89 | +```sh |
| 90 | +docker build --build-arg PHP_VERSION=8.2-cli -t not-empty/database-cache-php-lib:php82 -f contrib/Dockerfile . |
| 91 | +``` |
| 92 | + |
| 93 | +Access the container |
| 94 | +```sh |
| 95 | +docker run -v ${PWD}/:/var/www/html -it not-empty/database-cache-php-lib:php82 bash |
| 96 | +``` |
| 97 | + |
| 98 | +Install all dependences |
| 99 | +```sh |
| 100 | +composer install --dev --prefer-dist |
| 101 | +``` |
| 102 | + |
| 103 | +Run all validations |
| 104 | +```sh |
| 105 | +composer check |
| 106 | +``` |
| 107 | + |
| 108 | +**Not Empty Foundation - Free codes, full minds** |
0 commit comments