Jump to content

Permanent global variable


Azu

Recommended Posts

I would like to avoid having to read and write to files, if possible, since it is much faster to have it already loaded to begin with, then to constantly read and write large amounts of data to files =\

 

What do you mean about the global variable with eval? Can you please go into a bit more detail?

Link to comment
Share on other sites

I need something that will be permanent, meaning if the person formats their hardrive the variable will still be on the server. I need to use a lot of them, with large amounts of data in them, so I can't just write them to disk and read them off the disk over and over.

Link to comment
Share on other sites

I'm going to set up a little scenario here.

 

Let's say you type something in notepad on your computer at home.  Now let's say you want what you typed to be permanent.

 

Now I'm going to ask a stupid question.  Do you save the file to disk or do you just walk away from the computer and hope that what you typed will still be there 30 days later?  Keep in mind that this computer might be used for many, many other tasks that could potentially warrant a system restart.  In addition, environmental conditions could cause it to be turned off for hardware maintenance or repairs.

 

If you want the information to be permanent, you have one choice.  Save it to the server's hard disk.

 

You have two choices on how you do that:

 

1) Creating your own files with fopen, fwrite, fread, etc.

 

2) Database, MySQL seems to go hand-in-hand with PHP.

Link to comment
Share on other sites

In that scenario it would probably be better to save it to disk. My scenario is different though.

 

Let's say you have a file that is 900MBs in size, and you only need to restart the server it's on once every few months, and noone else uses it, and you have plenty of ram.

 

Do you save the the whole file to disk every time there is 1 modification and close it only to open it again a few seconds later, and do this over and over every few seconds, or do you just leave it open, and save it to disk once a day and have it load on startup?

 

I'm trying to find a way to accomplish the latter.

Link to comment
Share on other sites

Global variables should be avoided as much as possible, you seem hell bent on having them.... why?

 

You may have some luck setting up environment variables within Apache itself and then retrieving them through PHP. Seems alot of work for something that in all reality is just going to make your code less secure and a bit messy.

Link to comment
Share on other sites

I need to have a huge amount of data constantly being modified on a regular bases from many different connections. Reading and writing it to disk simply takes to long I have tried it already, so I need to find a way to keep it in ram. Unless you know of a better way? o_o

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.