UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'B8bHEKBKK7APEHA634KaycLWp0Xn+JU8m740uqyfD0k=' 
WHERE 
  key_id = '9264a4d8f2915548e71a5e56edb44e9d3c3c6d38739468b826b1c5dcb2a8477b' 
  AND (
    token = 'B8bHEKBKK7APEHA634KaycLWp0Xn+JU8m740uqyfD0k=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037