UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '3G8bRujd8y0OEsEb6g86uWAw8D3FzZl1echgVf6szY8='
WHERE
key_id = '87dff3938c14ce5c16728b116d38df10ef57603e803192db9a6e5d2f4064ee2e'
AND (
token = '3G8bRujd8y0OEsEb6g86uWAw8D3FzZl1echgVf6szY8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)