Rather than worry about doing it manually, I use a singleton that
objects register with that listens to objectsChangedInStore()
notifications. Any objects that keep cached arrays register
themselves with the singleton, which then notifies the app when the
object changes. Since EOF will send this notification even if only
children change, the parent gets notified and nulls the cache.
I also have this paired with a change notification system that uses a
message bus, so that even if the array gets modified from another
instance, the cache data still gets cleared.
Ken
On Aug 11, 2009, at 12:49 PM, Alan Ward wrote:
I usually cache it in the EO itself but I also add a refreshCaches()
method that I call when
something modifies the object graph in such a way that the cached
relationships may be
out of date. The refreshCaches method simply nulls out the private
NSArray. The accessor
then checks for null and only fetches if necessary.
Alan
On Aug 11, 2009, at 9:32 AM, Michael Halliday wrote:
Hi List,
Let's say you have in your model:
Customer -->> Transactions
Since a customer could have 1000's or 10000's transactions ...
obviously you wouldn't want to have transactions as a class
property on the Customer EO for performance reasons. Normally you
would never want to get at ALL the transactions for a customer at
once, but you might want to get "Open" transactions or "Flagged"
transactions. So, for example you could have a method on the
Customer EO that just fetches the Transaction with a qualifier as
below:
public NSArray<Transaction> openTransactions() {
return Transaction.fetchTransactions(editingContext(),
Transaction.CUSTOMER.eq(this).and(Transaction.STATUS.eq("Open")),
null);
}
Now, this is all well and good ... but what's the "best practice"
for caching this result? You wouldn't want to bind this method up
to a WORepetition for example! I'd just be curious to see how
other people are handling these situations. Do you cache this
stuff in the EO itself ... or do you just limit calls to such
methods and cache the return value? I'm basically describing the
role of Core Data's fetched properties.
Cheers,
Michael
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/award%40apple.com
This email sent to [email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/kenlists%40anderhome.com
This email sent to [email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]