You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> This is just **Annotations**, for **ORM** use [nettrine/orm](https://github.com/contributte/doctrine-orm) or **DBAL** use [nettrine/dbal](https://github.com/contributte/doctrine-dbal).
30
31
31
-
## Relying
32
-
33
-
Take advantage of empowering this package with 1 extra package:
34
-
35
-
- `doctrine/cache`
36
-
37
-
38
-
### `doctrine/cache`
32
+
## Configuration
39
33
40
-
This package can be enhanced with `doctrine/cache`, use prepared [nettrine/cache](https://github.com/contributte/doctrine-cache) integration.
You may omit the `cache` key using [nettrine/cache](https://github.com/contributte/doctrine-cache) to setup cache. It's configured automatically.
73
-
74
-
```yaml
75
-
nettrine.annotations:
76
-
debug: %debugMode%
77
-
```
78
-
79
-
80
59
## Usage
81
60
82
-
You can count on [Nette Dependency Injection](https://doc.nette.org/en/3.0/dependency-injection).
83
-
84
61
```php
85
62
use Doctrine\Common\Annotations\Reader;
86
63
87
-
class MyReader {
64
+
class MyReader
65
+
{
88
66
89
67
/** @var Reader */
90
68
private $reader;
@@ -102,17 +80,43 @@ class MyReader {
102
80
}
103
81
```
104
82
105
-
Register reader `MyReader` under services in NEON file.
83
+
You can create, define and read your own annotations. Take a look [how to do that](https://www.doctrine-project.org/projects/doctrine-annotations/en/2.0/index.html).
106
84
107
-
```yaml
108
-
services:
109
-
- MyReader
110
-
```
85
+
### Caching
86
+
87
+
> [!TIP]
88
+
> Take a look at more information in official Doctrine documentation:
A Doctrine Annotations reader can be very slow because it needs to parse all your entities and their annotations.
92
+
93
+
> [!WARNING]
94
+
> Cache adapter must implement `Psr\Cache\CacheItemPoolInterface` interface.
95
+
> Use any PSR-6 + PSR-16 compatible cache library like `symfony/cache` or `nette/caching`.
111
96
112
-
You can create, define and read your own annotations. Take a look [how to do that](https://www.doctrine-project.org/projects/doctrine-annotations/en/latest/index.html#create-an-annotation-class).
97
+
In the simplest case, you can define only `cache`.
98
+
99
+
```neon
100
+
nettrine.annotations:
101
+
# Create cache manually
102
+
cache: App\CacheService(%tempDir%/cache/orm)
103
+
104
+
# Use registered cache service
105
+
cache: @cacheService
106
+
```
113
107
108
+
> [!IMPORTANT]
109
+
> You should always use cache for production environment. It can significantly improve performance of your application.
110
+
> Pick the right cache adapter for your needs.
111
+
> For example from symfony/cache:
112
+
>
113
+
> -`FilesystemAdapter` - if you want to cache data on disk
114
+
> -`ArrayAdapter` - if you want to cache data in memory
115
+
> -`ApcuAdapter` - if you want to cache data in memory and share it between requests
116
+
> -`RedisAdapter` - if you want to cache data in memory and share it between requests and servers
117
+
> -`ChainAdapter` - if you want to cache data in multiple storages
0 commit comments