codetheweb / anylist

📋 a wrapper for AnyList's API (unoffical, reverse engineered)
81 stars 20 forks source link

Refactor retrieval of user data #42

Closed jchadwick closed 6 months ago

jchadwick commented 6 months ago

As it stands, all of the existing get* methods all GET from the same endpoint, which retrieves ALL user data every time. This PR refactors that to one method (in the first commit), and then also implements optional in-memory "caching" of the user data to avoid getting it every call.

NOTE: this implementation defaults to the existing behavior, which is to re-fetch the user data with every call, though adds an optional parameter to override this and use the cached data. Seemed prudent to make this change backwards-compatible, but if you're into making the default to use the cached data, that'd be cool!