OpenERP Cache Functions

I want to cache some results in my OpenERP module, so I reached out a bit and found a cache decorator . Unfortunately, most of the documents I could find are in the class declaration:

Use it as a decorator of the function you plan to cache. Timeout: 0 = no timeout, otherwise in seconds

Can anyone recommend a good example of how to use this? Are problems known?

+3
source share
2 answers

After you dig out another, the simplest example I have found is the ir_model_data._get_id () method :

@tools.cache()
def _get_id(self, cr, uid, module, xml_id):
    ids = self.search(cr, uid, [('module','=',module),('name','=', xml_id)])
    if not ids:
        raise ValueError('No references to %s.%s' % (module, xml_id))
    # the sql constraints ensure us we have only one result
    return ids[0]

, , , . , update(), :

            if not result3:
                self._get_id.clear_cache(cr.dbname, uid, module, xml_id)

, ( ).

. , .

+5

, LRU, .

http://bazaar.launchpad.net/~openerp/openobject-server/5.0/revision/2151

, : ( id ).

  • , skiparg
  • - self . , skiparg 2.
+3

Source: https://habr.com/ru/post/1753205/


All Articles