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
Copy file name to clipboardExpand all lines: docs/caching.md
+65-22Lines changed: 65 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -7,21 +7,64 @@ By caching data in a faster, more local storage location, the system can quickly
7
7
In Ellar, we provided several cache backends interface that interacts with different cache types to assist in cache endpoint responses or other relevant data.
8
8
9
9
## Setting up the cache
10
-
It's very simple to set up cache in Ellar but the crucial part is picking the cache type that is suitable for your application because some cache type behave differently and perform better and faster than others.
10
+
It's very simple to set up cache in Ellar but the crucial part is picking the cache type that is suitable for your application
11
+
because some cache type behave differently and perform better and faster than others.
11
12
12
-
The configuration of your cache defined in `CACHES` variable in `config.py` file.
13
+
To set up cache, we need to use `CacheModule`. `CacheModule` provides two methods, `CacheModule.register_setup` and `CacheModule.setup`, for setting up `cache` in ellar applications.
13
14
14
-
```python
15
-
# project_name/config.py
15
+
=== "CacheModule Register Setup"
16
+
This setup method requires you to defined `CACHES` variable containing
17
+
key value pairs of cache backends in `config.py` file.
18
+
19
+
for example:
20
+
21
+
```python
22
+
# project_name/config.py
23
+
24
+
from ellar.core import ConfigDefaultTypesMixin
25
+
from ellar.cache.backends.local_cache import LocalMemCacheBackend
In CacheModule.`setup`, the `default` parameter must be provided and other cache
67
+
backends will be defined as keyword-arguments just like `local` and `others` incase you want to set up more than one cache backend.
25
68
26
69
### **Memcached**
27
70
[Memcached](https://memcached.org/) is an entirely memory-based cache server, originally developed to handle high loads at LiveJournal.com and subsequently open-sourced by Danga Interactive.
@@ -273,7 +316,7 @@ class DevelopmentConfig(ConfigDefaultTypesMixin):
273
316
'default': PyMemcacheCacheBackend(
274
317
servers=['127.0.0.1:11211'],
275
318
options={'default_noreply': True},
276
-
timeout=300,
319
+
ttl=300,
277
320
version=1,
278
321
key_prefix='project_name'
279
322
)
@@ -296,7 +339,7 @@ from ellar.cache.backends.local_cache import LocalMemCacheBackend
0 commit comments