Anyone else have a cached_property that they want to re-create/re-run periodically after several accesses of the computed and cached value?
My use case is that I read and cache data then access the cached data several times. I flag the data for change, later get an external notification of the change being enacted and only then need to re-read/re-cache the updated data.
There are work-arounds, but thought i’d advertise a use. Thanks
Doh. It is stated right there in the docs as you stated! - I can’t read cos I already know and what I knew was b*llocks.
In [1]: from functools import cached_property
...:
...: def life():
...: print("Some expensive calc...")
...: return 42
...:
...: class Universe:
...:
...: @cached_property
...: def everything(self):
...: return life()
In [2]: u = Universe()
In [3]: u.everything
Some expensive calc...
Out[3]: 42
In [4]: u.everything
Out[4]: 42
In [5]: u.everything
Out[5]: 42
In [6]: del u.everything
In [7]: u.everything
Some expensive calc...
Out[7]: 42
In [8]: u.everything
Out[8]: 42
In [9]: u.everything
Out[9]: 42
In [10]: