diff --git a/README.md b/README.md index 94f9d2915aa8dd4c5db91405fd858693c4f977ac..5a8fea667c6bb50b119ef14c6ed579899be56352 100644 --- a/README.md +++ b/README.md @@ -126,12 +126,14 @@ LDP_RDF_CONTEXT = 'https://cdn.happy-dev.fr/owl/hdcontext.jsonld' DJANGOLDP_PACKAGES = [] SITE_URL = 'http://localhost:8000' BASE_URL = SITE_URL +SERIALIZER_CACHE = True ``` * `LDP_RDF_CONTEXT` tells DjangoLDP where our RDF [ontology](https://www.w3.org/standards/semanticweb/ontology) is defined, which will be returned as part of our views in the 'context' field. This is a web URL and you can visit the value to view the full ontology online. The ontology can be a string, as in the example, but it can also be a dictionary, or a list of ontologies (see the [JSON-LD spec](https://json-ld.org) for examples) * `DJANGOLDP_PACKAGES` defines which other [DjangoLDP packages](https://git.happy-dev.fr/startinblox/djangoldp-packages) we're using in this installation * `SITE_URL` is the URL serving the site, e.g. `https://example.com/`. Note that if you include the DjangoLDP urls in a nested path (e.g. `https://example.com/api/`), then `SITE_URL` will need to be set to this value * `BASE_URL` may be different from SITE_URL, e.g. `https://example.com/app/` +* `SERIALIZER_CACHE` Add a cache to Serializer (Set to True recommended) 4. You can also register your model for the django administration site diff --git a/djangoldp/serializers.py b/djangoldp/serializers.py index 9436412c48b8b890babb9d7cbb8aa37d1086a560..90dba77653cd866d065583ab37d86c8f7358e0b5 100644 --- a/djangoldp/serializers.py +++ b/djangoldp/serializers.py @@ -58,7 +58,7 @@ class LDListMixin: '''A Mixin for serializing containers into JSONLD format''' child_attr = 'child' - with_cache = True + with_cache = settings.SERIALIZER_CACHE to_representation_cache = InMemoryCache() @@ -304,7 +304,7 @@ class LDPSerializer(HyperlinkedModelSerializer): serializer_url_field = JsonLdIdentityField ModelSerializer.serializer_field_mapping[LDPUrlField] = IdURLField - with_cache = True + with_cache = settings.SERIALIZER_CACHE to_representation_cache = InMemoryCache() diff --git a/djangoldp/tests/perf_result.csv b/djangoldp/tests/perf_result.csv index 810ca0324db673ea95daf27f8c5454be67f25a2d..33d2f033490923f81080c5ac54527b537eb97bb3 100644 --- a/djangoldp/tests/perf_result.csv +++ b/djangoldp/tests/perf_result.csv @@ -46,3 +46,4 @@ jbl+AC0-T440p,Oct 09 2020 11:56:19,True,True,100,0.003119325637817,0.00560247182 jbl+AC0-T440p,Oct 09 2020 11:58:22,True,True,100,0.003008058071136,0.005401248931885,0.010658957958222,0.003909242153168,0.000718443393707,0.301162958145142,TRUE,3 jbl+AC0-T440p,Oct 09 2020 11:59:16,True,True,100,0.003015418052673,0.005526115894318,0.010740044116974,0.00400491476059,0.000724492073059,0.313828229904175,TRUE,4 jbl+AC0-T440p,Oct 09 2020 12:00:32,True,True,100,0.002969658374786,0.005434756278992,0.018136837482452,0.003030817508698,0.000726938247681,0.320115327835083,TRUE,0 +jbl-T440p,Oct 09 2020 12:21:00,True,True,100,0.0034934663772583007,0.0061032938957214355,0.019232537746429443,0.003091294765472412,0.0007375502586364747,0.36986708641052246,N/A diff --git a/djangoldp/tests/settings_default.py b/djangoldp/tests/settings_default.py index 3686e77775e31fcf1c30567e72db2896ae95c187..6773c2960879de046798131d2b78b80ffbeaf4fd 100644 --- a/djangoldp/tests/settings_default.py +++ b/djangoldp/tests/settings_default.py @@ -93,3 +93,4 @@ LDP_RDF_CONTEXT={ } SEND_BACKLINKS=False GUARDIAN_AUTO_PREFETCH = True +SERIALIZER_CACHE = True