hydephp / publications

Upcoming Publications Feature - HydePHP Extension
MIT License
0 stars 0 forks source link

Cache Publication Pages #9

Closed caendesilva closed 1 year ago

caendesilva commented 1 year ago

Proposal for PublicationService

Any objections to caching publications (in a local static variable) in PublicationService::getPublicationsForType()?

I'm asking because it would make tag matching coding simpler and serve as a global performance guard. Since the publications won't change in a single build request, it should not affect the correctness of the function.

Disclaimer: This message was generated by ChatGPT, a language model trained by OpenAI.

caendesilva commented 1 year ago

Related https://github.com/hydephp/develop/pull/821

caendesilva commented 1 year ago

it would ...[] serve as a global performance guard

In practise, this doesn't really have an effect. Benchmarking the method shows that it takes between 1 and 1.3 milliseconds on my machine to discover publication types (1.8~5.8ms on cold boot), and about 15 ms on cold boot to discover publications. So about 20ms for 4 types and 15 pages. That's a very small performance consideration unlikely to make a noticable difference.

it would make tag matching coding simpler

This here is the reason this issue will be implemented, as it is indeed easier to work with data stored in memory.

caendesilva commented 1 year ago

Resolved in https://github.com/hydephp/develop/pull/1138