UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'hMWsbc25gKRbUnF0xWZrAdN2M/WE9/jgBuznd6DW1do='
WHERE
key_id = 'b3961d157e5c830c58c5fcce328cfc85b6583fa418c8501c891d5f47075c0a31'
AND (
token = 'hMWsbc25gKRbUnF0xWZrAdN2M/WE9/jgBuznd6DW1do='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)