Generic cache of objects

前端 未结 3 1284
日久生厌
日久生厌 2021-01-11 14:16

Does anyone know any implementation of a templated cache of objects?

  • You use a key to find object (the same as in std::map<>)
  • You specify a maximum
3条回答
  •  终归单人心
    2021-01-11 14:26

    In an application I can hardly imagine it would speed/boost up performance to store objects that apparently can be re-created (hip: since they can be automatically discarded, when the cache tops). A sw cache would require memory-fetching through associativism code, surely slower then memory allocation and constructor running (mostly memory initializations).

    With the exception of manual user configuration to avoid the paging mechanism (precisely to boost performance, btw), most OS "caches" memory for you on disk... it's "paging", a form of "high-cost caching", because nothing gets thrown away, and it's done by specific HW, a sub-processing unit called Memory Management Unit...

    A caching-code, in the big picture, would be slowing processes while being redundant.

提交回复
热议问题