Class object persistance
Posted: 09 May 2005 07:10 PM   [ Ignore ]  
Summer Student
Total Posts:  2
Joined  05-09-2005

I am new to Expression Engines, actualy as of today, and I must compliment you on how simple and strait-forward the structure for plugins is.

But to the point, I am developing a custom plugin to interface with the <a href=“http://www.flickr.com/services/api”>Flickr API</a>, which responds with xml data. The plugin will be parsing the xml and printing out some of the xml data. What I am wondering is if there is just one instance of the plugin class instanciated the first time it is called per page, or if each “{exp:class:function}” instanciates a new class object. I ask because I need data persistance for as long as it takes to generate the page, in case multiple function calls occur, the goal being to reduce request to the Flickr API.

Profile
 
 
Posted: 09 May 2005 08:11 PM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7534
Joined  08-05-2002

Every instance of a plugin tag in a template has a new instantiation in the class called.  It is pretty common for plugin files to have default values in class variables, so we wanted a clean slate each time.

You could use either a constant or a superglobal to store data, if you want, since that will remain persistent.  Alternatively, you could create a caching system like those used by various other plugins grabbing data from off site.

 Signature 
Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64978 Total Logged-in Users: 24
Total Topics: 82015 Total Anonymous Users: 22
Total Replies: 440813 Total Guests: 193
Total Posts: 522828    
Members ( View Memberlist )