Kevin3374 Posted March 19, 2008 Share Posted March 19, 2008 When you implement a single-instance class, it allows one instance of this class for each instance of the script correct? In other words if 5 people are accessing the same script simultaneously, they each have their own instance of the class. But each individual user cannot create more than one instance of this class, correct? Link to comment https://forums.phpfreaks.com/topic/96968-very-quick-question-regarding-single-instancesingleton-classes/ Share on other sites More sharing options...
BlueSkyIS Posted March 19, 2008 Share Posted March 19, 2008 i have no idea, but google pointed me to this: http://www.sematopia.com/?p=216 Link to comment https://forums.phpfreaks.com/topic/96968-very-quick-question-regarding-single-instancesingleton-classes/#findComment-496213 Share on other sites More sharing options...
Kevin3374 Posted March 19, 2008 Author Share Posted March 19, 2008 i have no idea, but google pointed me to this: http://www.sematopia.com/?p=216 Yeh, I actually found that through google also, but it didn't answer my specific question. Link to comment https://forums.phpfreaks.com/topic/96968-very-quick-question-regarding-single-instancesingleton-classes/#findComment-496310 Share on other sites More sharing options...
roopurt18 Posted March 19, 2008 Share Posted March 19, 2008 You are correct. If there are 10 simultaneous requests from different users, then they will each get their own instance of the singleton. AFAIK, there is no built in mechanism to share data and objects between requests, but I've never looked into it. If you did want to share data between requests, then I'm sure you could. If there isn't a built in mechanism you could develop one of your own via permanent storage like a database. However you'd have to deal with broadcasting changes to the data, which I'm not sure how you'd accomplish that. Link to comment https://forums.phpfreaks.com/topic/96968-very-quick-question-regarding-single-instancesingleton-classes/#findComment-496338 Share on other sites More sharing options...
Kevin3374 Posted March 19, 2008 Author Share Posted March 19, 2008 You are correct. If there are 10 simultaneous requests from different users, then they will each get their own instance of the singleton. AFAIK, there is no built in mechanism to share data and objects between requests, but I've never looked into it. If you did want to share data between requests, then I'm sure you could. If there isn't a built in mechanism you could develop one of your own via permanent storage like a database. However you'd have to deal with broadcasting changes to the data, which I'm not sure how you'd accomplish that. Thank you. Good explanation. Link to comment https://forums.phpfreaks.com/topic/96968-very-quick-question-regarding-single-instancesingleton-classes/#findComment-496380 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.