From 051bae28ce429f6e4041ea073f40e6f012edbc95 Mon Sep 17 00:00:00 2001 From: Pelagic Date: Tue, 12 Sep 2023 13:44:47 +0300 Subject: [PATCH] Changed the formatting a bit in README.md --- README.md | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 77e848e..9b375e7 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ This repository holds the django library that StarFields uses for the django-res # Differences with the DRF generic views It changes the generic lifecycles of all the CRUD operations to fit within them automated caching functionality. Caching and deleting cache keys is handled by the library in a way that the cache keys have no duplicates. The generic views offered include single item CRUD and list-based CRUD. + To manage automated caching this the library replaces (and appends to) the DRF filters. These filters need a get_unique_dict method in order to avoid the duplicate cache keys problem. # Usage @@ -56,16 +57,18 @@ class SearchView(generics.CachedListRetrieveAPIView): ``` ### New class attributes that are used -cache_prefix: defines the prefix that the module will use when saving values in the cache -cache_vary_on_user: defines whether keys saved in the cache are different for each user, in which case extra user information will be added to the cache prefix -cache_timeout_mins: the cache key timeout -filter_backends: the filters that you want the view to have, each can be configured with view class attributes -ordering_fields: if you use the OrderingFilter you must indicate what fields the user can order by, the first element is used as the default order -search_fields: if you use the TrigramSearchFilter you must indicate the fields to search through -paged: your generic view can have a pager for the user to choose pages or it can be a full listing -default_page_size: the default size of the pages if a user has not indicated a page size -logger: you should register a logger in order to get error feedback in your deployments -cache: the main feature of this module is automated and organized caching, you should register your cache here +```python +cache_prefix = defines the prefix that the module will use when saving values in the cache +cache_vary_on_user = defines whether keys saved in the cache are different for each user, in which case extra user information will be added to the cache prefix +cache_timeout_mins = the cache key timeout +filter_backends = the filters that you want the view to have, each can be configured with view class attributes +ordering_fields = if you use the OrderingFilter you must indicate what fields the user can order by, the first element is used as the default order +search_fields = if you use the TrigramSearchFilter you must indicate the fields to search through +paged = your generic view can have a pager for the user to choose pages or it can be a full listing +default_page_size = the default size of the pages if a user has not indicated a page size +logger = you should register a logger in order to get error feedback in your deployments +cache = the main feature of this module is automated and organized caching, you should register your cache here +``` ### Extras The source code is similar to the django-rest-framework's generic classes and related objects, it should be eminently readable. A new method is added in each filter named get_unique_dict that aids in fixing the duplicate key problem.