0

When we are starting the PHP server online,if at that time we want to load an array having lot of records in the web application before any users visit the homepage.Because loading a big array will take a lot of time when users visit the site online.So i want to load it on server start,so that when user comes he should get everything ready...

How can we load an array having lacs of records in server on starting in PHP.

Pupil
  • 23,834
  • 6
  • 44
  • 66
user3488008
  • 59
  • 3
  • 10
  • Your requirement is not clear. Also, loading one lac records at a time is a huge mess up. – Pupil Apr 07 '14 at 06:23
  • What do you mean? You cannot have something loaded on the user's system without them visiting your website. Ideally, your PHP will be executed completely and only then your HTML, if you do not want a blank page while the loading occurs, you could use preloaders. – AyB Apr 07 '14 at 06:25
  • @ICanHasCheezburger- will give u an example,like in an ecommerce website.u have big catelog of elements,so we can load that list prior to user visit application.So that application loads the data with in one second when user visits.We can do in java by using server startup controller,which will load arraylist in context and will use that arraylist through out the application.I dont know how to do that in PHP,as i m new to PHP..Please guide me regarding above mentioned scenario.... – user3488008 Apr 07 '14 at 06:38
  • @user3488008 Where are the values of the array coming from? – AyB Apr 07 '14 at 11:02
  • arrays values are coming from an xml file which i m reading and storing values in array..... – user3488008 Apr 07 '14 at 12:08

1 Answers1

0

I believe you are asking how to load and store a shared list of content, that all users using the application can access. This is so that each time a user loads a page you don't have to load the contents from a database.

This can be done easily with Java, as you mentioned, but with PHP you'll have to push shared application data outside of PHP... MemCache is one option.

See: How to set a global variable accessible throughout the application

Community
  • 1
  • 1
Sprooose
  • 504
  • 1
  • 6
  • 17