UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Ed1P9Y0Xt2SbtAb4JcaLZspbNt7AHB7r6bFsP/ahqNk=' 
WHERE 
  key_id = '8d3938962efd05b80e6026c847ae5a8516cad5a2c3b801be2c5be20aeaf1158e' 
  AND (
    token = 'Ed1P9Y0Xt2SbtAb4JcaLZspbNt7AHB7r6bFsP/ahqNk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00068