mirror of
https://github.com/standardebooks/web.git
synced 2025-07-15 02:46:46 -04:00
Better error handling if a user tries to get a book while the library cache is being rebuilt
This commit is contained in:
parent
4acd88d08a
commit
74d3272c37
1 changed files with 15 additions and 1 deletions
|
@ -108,7 +108,21 @@ class Library{
|
||||||
}
|
}
|
||||||
catch(Safe\Exceptions\ApcuException $ex){
|
catch(Safe\Exceptions\ApcuException $ex){
|
||||||
Library::RebuildCache();
|
Library::RebuildCache();
|
||||||
$ebooks = apcu_fetch('ebooks');
|
try{
|
||||||
|
$ebooks = apcu_fetch('ebooks');
|
||||||
|
}
|
||||||
|
catch(Safe\Exceptions\ApcuException $ex){
|
||||||
|
// We can get here if the cache is currently rebuilding from a different process.
|
||||||
|
// Nothing we can do but wait, so wait 20 seconds before retrying
|
||||||
|
sleep(20);
|
||||||
|
|
||||||
|
try{
|
||||||
|
$ebooks = apcu_fetch('ebooks');
|
||||||
|
}
|
||||||
|
catch(Safe\Exceptions\ApcuException $ex){
|
||||||
|
// Cache STILL rebuilding... give up silently for now
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ebooks;
|
return $ebooks;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue