StaticDataContextDriver - how to cache data from the first call
Options
Hi.
I am loading a list of items when a driver runs the query for the first time. I would like to store it somewhere, so when the next query comes, I would like to use the cached list. Only when on the top level of the tree one selects "Refresh", then I would like to reload the initial list of items.
So far what I am observing is that running another query creates a new instance of the CustomType. So, what I am asking, I guess, is it possible to control the lifetime of the CustomType instance that is used for queries?
Thanks!
I am loading a list of items when a driver runs the query for the first time. I would like to store it somewhere, so when the next query comes, I would like to use the cached list. Only when on the top level of the tree one selects "Refresh", then I would like to reload the initial list of items.
So far what I am observing is that running another query creates a new instance of the CustomType. So, what I am asking, I guess, is it possible to control the lifetime of the CustomType instance that is used for queries?
Thanks!
Comments
-
ah, found it, I think: Util.Cache()
-
There's also an extension for enumerables to cache the results, aptly named `Cache()`.
-
If you're writing a driver, another option is to cache it in a static field in the driver, or any type that's defined in your driver assembly.