• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: refreshing the defaultEditingContext
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: refreshing the defaultEditingContext


  • Subject: Re: refreshing the defaultEditingContext
  • From: Dev WO <email@hidden>
  • Date: Tue, 16 May 2006 19:05:19 +0200

Thanks all for your answers and tips.
Based on all your suggestions, I took some time to learn more about Editing Context which I obviously don't know enough;)


So something I didn't knew was the ability to create an Editing Context without a session!
I'm actually trying to re-think my application data management.
The application is a 3-parts application:
-a framework
-a front office
-a back office


basically, both front office and back office can change things.
The front office cannot change many things and I can invalidate the objects to force a fetch to the datastore, so the editing part of the front office doesn't seemed to be an issue.
In the back office I'm forcing a refetch to the datastore every time a page is displayed, it's not "efficient" but it works and the back office is used by a couple of people only, so I'll try to optimize that later.


So my main concern is to optimize the front office:
-don't create session when they are not required
-try to limit the number of request to the datastore
-maybe try to share objects that are updated only ten times a day

Based on all your tips, I'll try to rewrite some part with an Editing context which is not in the session.
So here's my first questions:
-when creating an editing Context inside my direct action (like suggested by Robert), the Editing context gets created each time the action is called and so fetches the database every-time, right?
-if I'm creating an Editing Context inside a Component, I've got some sort of caching for this component shared among different users?
I mean if I have 2 visitors who are adding a commentary to a news for exemple, at the same time, when saveChanges is called, the last commentary posted will raise an exception complaining about the cache not the same as what's in the datastore (the first commentary was saved in between)? or maybe there's a way to tell the EC to just "add" the new entry?
-Is there anything like notification I could issue from the back office through the framework to invalidate a specific Editing context or a specific object?


I keep on working on that and try to better understand (time to re- read some books;)) Editing Context:)

Thanks for all your inputs:)

Xavier



I am sure there are many ways achieve freshness, however looking at the advanced WWDC sessions of recent years it seems these EOEditingContext methods are all you need to use to ensure freshness:


static setDefaultFetchTimestampLag(long lag) and creating new ec's regularly for EOF based transaction tasks


or


setFetchTimestamp(long timestamp) on an existing ec to now (new NSTimestamp() ) to ensure that any cached snapshots older than now are updated from the database.


In my experience, these methods alone are all you need to ensure fresh data.... but beware because fresh data means more SQL traffic to the database, and less use of EOF snapshot caches. I set an application wide setDefaultFetchTimestampLag to 120 seconds (the default is one hour) and setFetchTimestamp to now as desired in EC's where I need the latest instant data from the db. Also the setFetchTimestamp for the defaultEditingContext can be set to now or 30 seconds ago in the sleep method of Session.

HTH,

Kieran




On May 15, 2006, at 4:27 PM, Robert Walker wrote:

I wanna make sure I understand this correctly. You were originally using the session().defaultEditingContext() to fetch data for your RSS feed. I am assuming you are accessing the RSS feed from a direct action, so when accessing session() you are getting an unneeded session for each request.

You then decided to use the defaultSharedEditingContext in place of the session().defaultEditingContext() to prevent the creation of a new session.

If this is accurate them my first question would be: Why did you not create a new instance of EOEditingContext and use that instead of session().defaultEditingContext()? This will prevent creating a new session for each request and will not have the issues related to the shared editing context.

You should also examine the documentation on "Fetching Data > Ensuring Fresh Data" in this document:

http://developer.apple.com/documentation/WebObjects/ Enterprise_Objects/index.html

Example:

	public WOActionResults myRSSFeedAction() {
		EOEditingContext ec = new EOEditingContext();

		ec.lock();

		/* Fetch your data and generate RSS feed here */

		ec.unlock();
	}


On May 15, 2006, at 2:57 PM, Dev WO wrote:

Hi guys,
I've been trying to optimize my application a little as I had some RSS feed which was actually creating a session and finally as RSS readers update themselves every x minutes, I just couldn't softly restart the instance.
So I moved the RSS component using the defaultSharedEditingContext, making sure no session was created. So this part was ok so far.
But trying it I saw that the data from the defaultSharedEditingContext didn't update...
I can afford some delay for the update like minutes, but it's been 5 hours now:(


How should I make the sharedEC to update itself? The data are being edited/added using another WOApplication, so maybe the other application could "call" the sharedEC to make it refresh...

Or do:
setRefreshesRefetchedObjects(true);
on the fetch specification should work?

Thanks a lot for any tip:)

Xavier

_______________________________________________ WebObjects-dev mailing list email@hidden http://www.omnigroup.com/mailman/listinfo/webobjects-dev

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40anazys.com


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: refreshing the defaultEditingContext
      • From: Ken Anderson <email@hidden>
References: 
 >refreshing the defaultEditingContext (From: Dev WO <email@hidden>)
 >Re: refreshing the defaultEditingContext (From: Robert Walker <email@hidden>)
 >Re: refreshing the defaultEditingContext (From: Kieran Kelleher <email@hidden>)

  • Prev by Date: Inheritance Problem
  • Next by Date: Re: Inheritance Problem
  • Previous by thread: Re: refreshing the defaultEditingContext
  • Next by thread: Re: refreshing the defaultEditingContext
  • Index(es):
    • Date
    • Thread