diff --git a/docs/advanced_usage.md b/docs/advanced_usage.md index fa65b0e..7b65ad4 100644 --- a/docs/advanced_usage.md +++ b/docs/advanced_usage.md @@ -27,4 +27,12 @@ $userRepository->findBy(['name' => 'John']); // Will retrieve all users with the $userRepository->findBy(['name' => 'John'], ['age' => 'ASC']); // Will retrieve all users with the name 'John' sorted by age in ascending order $userRepository->findBy(['name' => 'John'], ['age' => 'ASC'], 5); // Will retrieve 5 users with the name 'John' sorted by age in ascending order $userRepository->count(['name' => 'John']); // Will retrieve an integer representing the number of users with the name 'John' -``` \ No newline at end of file +``` + +## Repository + +You can create your own repository to query your objects in Redis. Then inject it in the +`#[RedisOm\Entity(repository: YourCustomRepository::class)]` attribute to use it. + +Then in each custom repository you can add custom methods to query your objects in Redis. + diff --git a/docs/installation.md b/docs/installation.md index e69de29..9f64896 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -0,0 +1,34 @@ +# Installation + +### PHP +To use the library you need a php-version >= 8.2 and the Redis extension installed. +If you don't have the Redis extension installed, you can use your favorite Redis client (for example Predis), +and create a new class that implements the `RedisClientInterface` interface, then inject it directly in the `#[RedisOm\Entity(client: YourRedisClient::class)]` attribute. + + +### Redis +You need a Redis server with a version >= 4.0. If you want to use the [JSON](https://redis.io/docs/latest/develop/data-types/json/) data type +you need a Redis server with the JSON module installed. By default, the library uses the HASH format type to store objects in Redis, which does not need any module. +But for indexing our objects and create the schema, you will need the [Redisearch](https://redis.io/search/) module installed. + +We recommend using the [Redis stack](https://redis.io/about/about-stack/) to get all modules you need. + +### Composer + +Install the library by running the following command: + +```console +composer require talleu/php-redis-om +``` + +Or add the library to your `composer.json` file: + +```json +{ + "require": { + "talleu/php-redis-om": "*" + } +} +``` + +Then run `composer update` to install the library. \ No newline at end of file diff --git a/docs/mapping.md b/docs/mapping.md index ce010ac..8058b5b 100644 --- a/docs/mapping.md +++ b/docs/mapping.md @@ -3,7 +3,7 @@ ## Mapping object -You can customize the mapping configuration by adding parameters to you RedisOm\Entity attribute. +Customize the mapping configuration by adding parameters to you RedisOm\Entity attribute. ```php value` or `RedisFormat::JSON->value`. +But be careful, if you switch the format in an entity that already has data stored in Redis, you will lose all the index stored in the previous format. + +Dont forget to run the migration command after changing the format of an entity. + +```console +vendor/bin/redisMigration +``` + ## Mapping properties ```php diff --git a/src/Om/Mapping/Entity.php b/src/Om/Mapping/Entity.php index 96b99cb..5917071 100644 --- a/src/Om/Mapping/Entity.php +++ b/src/Om/Mapping/Entity.php @@ -23,7 +23,6 @@ final class Entity { public function __construct( public ?string $prefix = null, - public ?int $expires = null, public ?string $format = null, public ?PersisterInterface $persister = null, public ?ConverterInterface $converter = null,