UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'd1jwdAid4ZqyZvOd0gUvVCFDwVdhn62MtXwP6OMpJsw='
WHERE
key_id = 'd1afd972777e68cc65f7d7e0f724de76e894be4b1e159394ee211226aac83fe3'
AND (
token = 'd1jwdAid4ZqyZvOd0gUvVCFDwVdhn62MtXwP6OMpJsw='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)