Hey there,
I'm writing a caching class, which writes the buffer that's built up to a .php file
$cache = new CacheClass;
$hello = "why hello there";
$hi = "some data";
$cache->begin();
$cache->additem("variable_name", $hello);
$cache->additem("another_var_name", $hi);
$cache->store("session_name", 60); // 60 seconds
$my_data = $cache->get("session_name");
echo $my_data['variable_name']; // why hello there
echo $my_data['another_var_name']; // some data
where store() would save a file containing:
<?php
$expire_time = 12345; // (would be time() + 60)
$cachedata['variable_name'] = "why hello there";
$cachedata['another_var_name'] = "some data";
?>
get() would include() this php file, and return the array.
Now that's all fine and dandy, but what happens if the file is being written to (I have file locking in plage) and it is requested?
What would include() do? Would it wait for it to be free to read? Would it skip over it and pretend nothing happened? Or would it give me an error?
Due to the nature of this, it's going to be hard to test this, so i'm asking for your help 🙂