I want to create a counter in PHP. Just a counter, nothing else. What's the best way to store the state of the counter?
EDIT 2:
Example 1(in pseudocode):
//Page is requested
obtain_lock();
$currentcounter=get_count();
$newcounter=$currentcounter+1
write_count($newcounter+1);
release_lock();
echo $newcounter;
Example 2(in pseudocode):
//Page is requested
atomic_inc_count();
echo get_count();
My question: what to use for get_count and write_count, or atomic_inc_count? A SQL DB? A file? What are the pro's and cons for using a file with locking vs a full-fledged database? What would you use?
EDIT 3: To clarify: I'm not actually looking for "thé approach", or one that is specifically tailored to my situation. I'm more hoping to see a couple of options with pro's and cons