UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '1aHDupJx1bl/3Obiz79ny+KZ1HtHyGd50Rlylve7XCU='
WHERE
key_id = '77183f73a8fae727428f4b1a56fe5951a27393719b4a7c0c1aa0a968e242303b'
AND (
token = '1aHDupJx1bl/3Obiz79ny+KZ1HtHyGd50Rlylve7XCU='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)