biothings.api icon indicating copy to clipboard operation
biothings.api copied to clipboard

allow customize cache settings

Open newgene opened this issue 2 years ago • 0 comments

Current default cache setting (7 days) is defined in BaseAPIHandler:

https://github.com/biothings/biothings.api/blob/7131379975e8f8aafafa5858ea274dc8181bc863/biothings/web/handlers/base.py#L67

To make it more flexible to customize, we can allow

  • set a global caching time in config.py to override the default value.

    API_HANDLER_CACHE = 3600
    
  • set caching time on per-handler base, likely in initialize method. Similar to how biothings_type parameter was set:

https://github.com/biothings/biothings.api/blob/7131379975e8f8aafafa5858ea274dc8181bc863/biothings/web/handlers/query.py#L57

it can be set like:

(r"/api/query/?", "biothings.web.handlers.QueryHandler", {"biothing_type": "schema", "cache": 3600}),

newgene avatar Mar 07 '22 21:03 newgene