• Facebook
  • 트위터
  • 유튜브
  • 라인드인
  • RSS
  • 기술 문서
  • 비교
  • 블로그
  • 다운로드
  • 문의하기
다운로드
목차 표시/숨기기

SQL을 사용하여 명명된 태그로 데이터 검색

당신이 사용할 수 객체 쿼리 분산 캐시에서 항목을 검색하려면 다음을 지정하십시오. 명명된 태그 검색 기준으로 사용하세요. NCache SQL 쿼리에 제공된 명명된 태그에 따라 캐시를 검색하는 고성능 SQL 유사 쿼리 메커니즘을 제공합니다. 검색하기 전에 항목이 명명된 태그와 함께 캐시에 추가되었는지 확인하십시오. 자세한 내용은 다음을 참조하십시오. 명명된 태그가 있는 항목 추가 섹션에서 명명된 태그 생성 및 추가에 대한 자세한 내용을 확인하세요.

사전 조건

사용하기 전에 NCache 클라이언트 측 API를 사용할 때는 다음 필수 조건을 충족해야 합니다.

  • . NET
  • 자바
  • Python
  • Node.js를
  • 레거시 API
  • .NET 클라이언트 애플리케이션에 다음 NuGet 패키지를 설치하세요.
    • 기업 : Alachisoft.NCache.SDK
    • 오픈 소스 : Alachisoft.NCache오픈소스 SDK
  • 애플리케이션에 다음 네임스페이스를 포함합니다.
    • Alachisoft.NCache.고객
    • Alachisoft.NCache.런타임.예외
    • Alachisoft.NCache.런타임.캐싱
    • Alachisoft.NCache.클라이언트.서비스
  • 캐시가 실행 중이어야 합니다.
  • 추가되는 데이터가 직렬화 가능.
  • 사용자 정의 클래스/검색 가능한 속성 절대로 필요한 것 에 설명된 대로 인덱싱됩니다. 쿼리 인덱스 구성.
  • API 세부 정보는 다음을 참조하세요. 아이캐시, ICacheReader, 쿼리 명령, ExecuteReader, 검색 서비스.
  • Java 클라이언트 애플리케이션에 대해 다음 Maven 종속성을 추가합니다. pom.xml 파일 :
<dependency>
    <groupId>com.alachisoft.ncache</groupId>
    <!--for NCache Enterprise-->
    <artifactId>ncache-client</artifactId>
    <version>x.x.x</version>
</dependency>
  • Java 클라이언트 애플리케이션에서 다음 패키지를 가져옵니다.
    • import **클라이언트 이름**
    • import com.alachisoft.ncache.런타임.예외.*;
    • import 영어: com.alachisoft.ncache.runtime.caching.*;
  • 캐시가 실행 중이어야 합니다.
  • 추가되는 데이터가 직렬화 가능.
  • 사용자 정의 클래스/검색 가능한 속성 절대로 필요한 것 에 설명된 대로 인덱싱됩니다. 쿼리 인덱스 구성.
  • API 세부 정보는 다음을 참조하세요. 캐시, 캐시 리더, 실행 리더, 쿼리 명령, getSearchService.
  • Python 클라이언트 애플리케이션에 다음 패키지를 설치하세요.
    • 기업 : ncache-클라이언트
  • 애플리케이션에서 다음 패키지를 가져옵니다.

    • 에 ncache.client 가져오기*
    • 에 ncache.runtime.caching 가져오기 *
    • 에 ncache.client.services 가져오기 *
  • 캐시가 실행 중이어야 합니다.

  • 추가되는 데이터가 직렬화 가능.
  • 사용자 정의 클래스/검색 가능한 속성 절대로 필요한 것 에 설명된 대로 인덱싱됩니다. 쿼리 인덱스 구성.
  • API 세부 정보는 다음을 참조하세요. 캐시, 실행 판독기, get_search_service, 쿼리 명령.
  • Node.js 클라이언트 애플리케이션에 다음 모듈을 설치하고 포함시키세요.
    • 기업 : ncache-클라이언트
  • 애플리케이션에 다음 클래스를 포함합니다.
    • 캐시
    • NamedTags사전
  • 캐시가 실행 중이어야 합니다.
  • 추가되는 데이터가 직렬화 가능.
  • 사용자 정의 클래스/검색 가능한 속성 절대로 필요한 것 에 설명된 대로 인덱싱됩니다. 쿼리 인덱스 구성.
  • API 세부 정보는 다음을 참조하세요. 캐시, 실행 리더, 쿼리 명령, 캐시 리더, getSearchService.
  • .NET 클라이언트 애플리케이션에 다음 NuGet 패키지 중 하나를 설치하세요.
    • 기업 : Install-Package Alachisoft.NCache.SDK -Version 4.9.1.0
  • 새로운 콘솔 애플리케이션을 만듭니다.
  • 추가되는 데이터가 직렬화 가능.
  • 추가 NCache 참고자료 위치를 찾아서 %NCHOME%\NCache\bin\assembly\4.0 추가 Alachisoft.NCache.Web Alachisoft.NCache.Runtime 적절한.
  • 포함시키다 Alachisoft.NCache.Web.Caching 애플리케이션의 네임스페이스.
  • 에 대한 자세한 내용을 보려면 NCache 레거시 API를 다운로드하세요 NCache 4.9 문서는 다음과 같이 사용 가능합니다. .지퍼 에 파일 Alachisoft 웹 사이트.

다음 예에서는 고객 명명된 태그 값이 제공된 값과 일치하는 캐시에서 가져옵니다.

  • . NET
  • 자바
  • Python
  • Node.js를
  • 레거시 API
try
{
  // Precondition: Cache is already connected

  // Create an SQL Query with the specified criteria
  // Make sure to use the Fully Qualified Name for custom class
  string query = "SELECT CustomerID,ContactName FROM FQN.Customer WHERE VIP_Membership_Discount = 0.12 ";

  // Use QueryCommand for query execution
  var queryCommand = new QueryCommand(query);

  // Executing the Query
  ICacheReader reader = cache.SearchService.ExecuteReader(queryCommand);

  // Read results if the result set is not empty
  if (reader.FieldCount > 0)
  {
      while (reader.Read())
      {
          // Get the value of the result set
          string customerID = reader.GetValue<string>("CustomerID");
          string customerName = reader.GetValue<string>("ContactName");

          Console.WriteLine($"Customer '{customerName}' with ID '{customerID}' has VIP membership discount.");
      }
  }
  else
  {
      Console.WriteLine($"No VIP members found");
  }
}
catch (OperationFailedException ex)
{
    if (ex.ErrorCode == NCacheErrorCodes.INCORRECT_FORMAT)
    {
        // Make sure that the query format is correct
    }
    else
    {
        // Exception can occur due to:
        // Connection Failures 
        // Operation Timeout
        // Operation performed during state transfer    
    }
}
catch (Exception ex)
{
    // Any generic exception like ArgumentException, ArgumentNullException    
}  
try
{
  // Precondition: Cache is already connected

  // Create an SQL Query with the specified criteria
  // Make sure to use the Fully Qualified Name for custom class

  // Create an SQL Query with the specified criteria
  String query = "SELECT customerID,contactName FROM FQN.Customer WHERE VIP_Membership_Discount = 0.12";

  // Use QueryCommand for query execution
  QueryCommand queryCommand = new QueryCommand(query);

  // Executing the Query
  CacheReader reader = cache.getSearchService().executeReader(queryCommand);

  // Read results if the result set is not empty
  if (reader.getFieldCount() > 0)
  {
      while (reader.read()) {
          // Get the value of the result set
          String customerID = reader.getValue("customerID", String.class);
          String customerName = reader.getValue("contactName", String.class);

          System.out.println("Customer '" + customerName + "' with ID '" + customerID + "' has VIP membership discount.");
      }
  }
  else
  {
      System.out.println("No VIP members found");
  }
}
catch (OperationFailedException ex)
{
    if (ex.getErrorCode() == NCacheErrorCodes.INCORRECT_FORMAT)
    {
        // Make sure that the query format is correct
    }
    else
    {
        // Exception can occur due to:
        // Connection Failures
        // Operation Timeout
        // Operation performed during state transfer
    }
}
catch (Exception ex)
{
    // Any generic exception like IllegalArgumentException or NullPointerException 
}  
try:
    # Precondition: Cache is already connected
    # Items are already present in the cache with Named Tags
    # Custom class is query indexed through the NCache Management Center or config.ncconf

    # Create SQL Query with the specified criteria
    # Make sure to use the Fully Qualified Name(FQN)
    query = "SELECT $Value$ FROM FQN.Customer WHERE VIP_Membership_Discount = 0.12 "

    # Use QueryCommand for query execution
    query_command = ncache.QueryCommand(query)

    parameter = {"VIP_Membership_Discount": 0.12}
    query_command.set_parameters(parameter)

    # Executing query
    search_service = cache.get_search_service()
    reader = search_service.execute_reader(query_command)

    # Check if result set is not empty
    if reader.get_field_count() > 0:
        while reader.read():
            # Get the value of the result set
            result = reader.get_value(Product, 1)
    else:
        # None query result set retrieved
        print("Query result is None")

except Exception as error:
    # Exception can occur due to:
    # Connection Failures
    # Operation Timeout
    # Operation during state transfer
    print("An error occurred:", str(error))
try 
{  
  // This is an async method
  // Precondition: Cache is already connected

  // Items are already present in the cache with Named Tags
  // Custom class is query indexed through the NCache Management Center or config.ncconf
  // Create SQL Query with the specified criteria
  // Make sure to use the Fully Qualified Name (FQN)
  var query = "SELECT $Value$ FROM FQN.Customer WHERE VIP_Membership_Discount = 0.12 ";

  // Use QueryCommand for query execution
  var queryCommand = new ncache.QueryCommand(query);

  let parameter = new Map();
  parameter.set("FlashSaleDiscount", 0.5);
  queryCommand.setParameters(parameter);

  // Executing query
  var searchService = await this.cache.getSearchService();

  var reader = await searchService.executeReader(queryCommand);

  // Check if result set is not empty
  if (reader.getFieldCount() > 0)
  {
      while (reader.read())
      {
          // Get the value of the result set
          var result = reader.getValue(1, ncache.JsonDataType.Object);
      }
  }
  else
  {
      // Null query result set retrieved
  }
} 
catch (error)
{
    // Handle errors
}  
// Using NCache Enterprise 4.9.1
try
{
  // Precondition: Cache is already connected

  // Create an SQL Query with the specified criteria
  // Make sure to use the Fully Qualified Name for custom class
  string query = "SELECT FQN.Customer WHERE this.VIP_Membership_Discount = ?";

  // Create a parameter list using Hashtable
  Hashtable values = new Hashtable();
  values.Add("VIP_Membership_Discount", 0.12);

  // Executing the query 
  ICacheReader queryResult = cache.ExecuteReader(query, values, true);

  // Read results if the result set is not empty
  if (queryResult.FieldCount > 0)
  {
      while (queryResult.Read())
      {
          // Get the value of the result set 
          string customerID = (string)queryResult["CustomerID"];
          string customerName = (string)queryResult["ContactName"];

          Console.WriteLine($"Customer '{customerName}' with ID '{customerID}' has VIP membership discount.");
      }
  }
  else
  {
      Console.WriteLine("No VIP members found");
  }
}
catch (OperationFailedException ex)
{
    if (ex.ErrorCode == NCacheErrorCodes.INCORRECT_FORMAT)
    {
        // Make sure that the query format is correct
    }
    else
    {
        // Exception can occur due to:
        // Connection Failures 
        // Operation Timeout
        // Operation performed during state transfer    
    }
}
catch (Exception ex)
{
    // Any generic exception like ArgumentException, ArgumentNullException    
}
주의 사항

작업이 안전하도록 하려면 에 설명된 대로 응용 프로그램 내에서 잠재적인 예외를 처리하는 것이 좋습니다. 처리 실패.

경고

동일한 캐시를 공유하는 여러 애플리케이션이 있고 모두 명명된 태그를 추가해야 하는 경우 동일한 명명된 태그가 동일한 데이터 유형을 가지고 있는지 확인하세요. 예를 들어 한 클라이언트가 명명된 태그를 추가하는 경우 고객 ID 문자열 데이터 유형을 사용하는 경우 다른 모든 클라이언트는 다음 값을 추가해야 합니다. 고객 ID 동일한 캐시에 대한 문자열 형식으로만 가능합니다.

개체 쿼리에 대한 자세한 내용은 다음을 참조하세요. 에 대한 SQL 참조 NCache 안내

추가 자료

NCache 명명된 태그에 대한 샘플 애플리케이션을 제공합니다. GitHub의.

도 참조

.그물: Alachisoft.NCache.런타임.캐싱 네임 스페이스.
자바 : com.alachisoft.ncache.런타임.캐싱 네임 스페이스.
Node.js : NamedTags사전 클래스입니다.
파이썬 : ncache.런타임.캐싱 클래스입니다.

문의하기

전화

+1 214-619-2601   (미국)

+44 20 7993 8327   (UK)

 
이메일

sales@alachisoft.com

support@alachisoft.com

NCache
  • 판 비교
  • NCache 아키텍처
  • 벤치 마크
다운로드
가격
놀이터를 사용해보십시오

배포
  • 클라우드(SaaS 및 소프트웨어)
  • 온 프레미스
  • Kubernetes
  • 도커
기술 사용 사례
  • ASP.NET 세션
  • ASP.NET 코어 세션
  • 게시/구독 메시징
  • 실시간 ASP.NET SignalR
  • 사물의 인터넷 IOT ()
  • NoSQL 데이터베이스
  • 스트림 처리
  • 마이크로 서비스
리소스
  • 잡지 기사
  • 제XNUMX자 기사
  • 기사
  • 비디오
  • 백서
  • 쇼
  • 회담
  • 블로그
  • 기술 문서
고객 사례 연구
  • 환자 후기
  • 고객
고객 지원
  • 데모 예약
  • 포럼(Google 그룹스)
  • Tips
회사
  • Leadership
  • 파트너
  • ​뉴스
  • 이벤트
  • 채용 정보
문의하기

  • 영어중국어 (간체)프랑스어독일 사람이탈리아 사람일본제한국어포르투갈어스페인어

  • 문의하기
  •  
  • 사이트 맵
  •  
  • 이용 약관
  •  
  • 개인정보 처리방침
© 저작권 Alachisoft 2002 - . 판권 소유. NCache 는 Diyatech Corp.의 등록상표입니다.
맨 위로