Bug 1025159 - [XMLRPC] Cache Product to save resources
Summary: [XMLRPC] Cache Product to save resources
Keywords:
Status: NEW
Alias: None
Product: TCMS
Classification: Other
Component: XMLRPC
Version: Devel
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: 3.9.0
Assignee: Yang Ren
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-10-31 06:47 UTC by cqi
Modified: 2015-12-01 05:37 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed:


Attachments (Terms of Use)

Description cqi 2013-10-31 06:47:42 UTC
It wastes resources to get a whole Product object repeatedly each time methods get called, which is only for constructing QuerySet search criteria. Cache every Product object's ID got previously will save much resources.

The cache could be a simple dict, maintaining the mapping from id and name to Product's id individually. Like this,
{
    1: 1, 'Product 1 name': 1,
    2: 2, 'Product 2 name': 2,
    ....
}

Here, we really don't need to map to a whole Product object, the ID is enough.

Meanwhile, with this cache, it's possible to simplify pre_check_product method also.


Note You need to log in before you can comment on or make changes to this bug.