UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Ww63wBPfDwY3/ZdHZpuOb3MY7jV19Xvt5INUFq4Gw1g=' 
WHERE 
  key_id = '1f9c86fb010e057d4c46948528306201b9e181213128943d003421567650249f' 
  AND (
    token = 'Ww63wBPfDwY3/ZdHZpuOb3MY7jV19Xvt5INUFq4Gw1g=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00043