Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - Server side variables that will "live" for ever?

I'm looking for a simple way to store a counter in the server memory to allow page load selection, kind of (pseudocode):

if counter is odd then load page-x 
else (even counter)  load page-y
increment counter by 1
store counter in server's memory

Session variables would not help, among multiple users.

I understand this could be achieved storing a field into the database, but this seems a cloggy approach. Was wondering for something faster.

That's why I thought about some server side variables that are kept in memory across sessions....

like image 627
Riccardo Avatar asked Dec 04 '22 10:12

Riccardo


1 Answers

Use APC, xCache, or memcache to save variables to cache instead of a database. Note however that a server reset will wipe out these values.

like image 77
bcosca Avatar answered Dec 18 '22 10:12

bcosca