PDA

View Full Version : PHP saving data


uplight
02-09-2012, 11:13 PM
Hi All

I need to have something like shared object on server between 5 clients querying every 5 sec for updates
It is only 10 variables with values of last update time;
Updates can come every minute

So what would be the best way regarding performance ?

1. read/write .ini file
2. update/select_all mysql table
3. update/select_all sqlite table
4. read/write xml file
5. ????????

uplight
02-13-2012, 04:21 AM
I know it is wrong forum for PHP thread but can't believe no opinion for my question

You can pass JAVA but not PHP if you dealing with Flash

peptobismol
02-13-2012, 08:53 PM
You can pass name pair values via form and save the data to a mysql database. You don't save actual objects.

uplight
02-14-2012, 12:03 AM
I have the same swf running on on 5 clients computer. They querying server every 5 sec for the updates sending the timestamp of their version . PHP side reading this file


feed1=60
feed2=60
feed3=60
feed4=60
feed5=60
feed6=60
feed7=60
leader=127.0.0.1
lastupdate=1329092453
feed1check=1329092439
feed2check=1329092441
feed3check=1329092443
feed4check=1329092446
feed5check=1329092449
feed6check=1329092451
feed7check=1329092453


where feed1check, feed2check..... timestamp of server version.
and feed1, feed2 .... are maximum allowable delay of each feed respectively.

when delay over its trigger update function and this file gets overwritten with new timestamps.

Because PHP is stateless My question is what for PHP appropriate way to keep variables shared between clients consider read data every second and save data every minute 24/7 running application on clients computers.


right now I'm using read_ini_file() and file_put_contents()

peptobismol
02-14-2012, 01:42 AM
Sounds you need to use xml socket server. It's a way to have multiple computers share states off one swf.

uplight
02-15-2012, 12:49 AM
how does socket server work on PHP side?
any links or examples?

peptobismol
02-15-2012, 03:47 AM
I don't have a link on hand but you can google. The only caveat is you need a static ip on most shared server service to open a port beside 80. You also need a script in php or java or whatever to listen to that certain port all the time. Search flash php socket server.

If this is beyond your capability, I guess you can have listen/send in info to a database every x seconds. Every user/computer should have their own row in the db table. This should de done by only a few computers. Writing to file would be a mess.

uplight
02-18-2012, 09:50 AM
No difference for me write file or database if only a couple lines needed.
After googling I found out best solution to keep temp data would be in cache with APC extension but it could be for objects only. what I have is associative array of integers.
in case of database I can convert indexes into integers to have select work faster.

php class:

const FEED1=1
const FEED2=2
const FEED3=3
const FEED4=4
...........................
const LASPUPDATE=9
const FEED1CHECK=10
const FEED2CHECK=11

...............................


so my table will look like this:

1=60
2=60
3=60
4=60
5=60
6=60
7=60
8=127.0.0.1
9=1329092453
10=1329092439
11=1329092441
12=1329092443
13=1329092446
14=1329092449
15=1329092451
16=1329092453


From all reading for small data SQLIte should work faster read/write then MySQL When I did testing MySQL gave better results But I use SQLIte:PDO driver and my database was fragmented. I want to try make only one table database to clear results.

And after I want to try APC extention

Right now I have parse_ini_file() and file_put_contents() what works for me because I have 5 clients reading every 5 sec and one client writing every 10 sec the same file