UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'H+2HwjybP5BIau27HX0SttAjlsjp018geHE0osqDtOo=' 
WHERE 
  key_id = '8d9d85a45948629f21441aa09f44e705b716bb771e868c9b37d6098fd07d8f11' 
  AND (
    token = 'H+2HwjybP5BIau27HX0SttAjlsjp018geHE0osqDtOo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00079