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

캐시의 데이터 구조에 대한 검색 가능한 속성 구성

NCache 이 기능을 사용하면 HashSet, List, Queue와 같은 분산 데이터 구조를 검색 가능한 메타데이터와 연결하여 구성할 수 있습니다. 데이터 구조는 다음과 같은 검색 가능한 속성과 연결될 수 있습니다.

  • 그룹
  • 태그
  • 명명된 태그

이러한 검색 가능한 속성은 에 설명된 대로 모든 관련 항목을 쿼리하는 데 사용할 수 있습니다. 데이터 구조 쿼리. 예를 들어, a CacheItem HashSet은 같은 그룹에 속할 수 있습니다. 이러한 속성은 다음을 사용하여 지정됩니다. DataTypeAttributes 클래스입니다.

중대한

데이터 구조가 생성된 후에는 이러한 속성을 수정할 수 없습니다. 하지만 데이터 구조 자체는 수정할 수 있습니다.

사전 조건

사용하기 전에 NCache 클라이언트 측 API를 사용할 때 다음 전제 조건을 충족하는지 확인하십시오.

  • . NET
  • 자바
  • Node.js를
  • .NET 클라이언트 애플리케이션에 다음 NuGet 패키지를 설치하세요.
    • 기업: Alachisoft.NCache.SDK
    • 오픈 소스: Alachisoft.NCache오픈소스 SDK
  • 애플리케이션에 다음 네임스페이스를 포함합니다.
    • Alachisoft.NCache.고객
    • Alachisoft.NCache.런타임.예외
    • Alachisoft.NCache.클라이언트.데이터 유형
    • Alachisoft.NCache.Client.DataTypes.Collections
    • Alachisoft.NCache.런타임.캐싱
    • Alachisoft.NCache.런타임.이벤트
  • 캐시가 실행 중이어야 합니다.
  • 추가되는 데이터가 직렬화 가능.
  • API 세부 정보는 다음을 참조하세요. 아이캐시, 데이터 유형 속성, NamedTags사전, 꼬리표, 태그, 그룹, 명명된 태그, IDistributedHashSet, 데이터 유형 관리자, CreateHashSet, 포함, 카운트, 추가.
  • 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.client.데이터 구조.*;
    • import com.alachisoft.ncache.runtime.dependencies.*;
    • import 영어: com.alachisoft.ncache.runtime.caching.*;
    • import com.alachisoft.ncache.runtime.caching.NamedTagsDictionary.*;
  • 캐시가 실행 중이어야 합니다.
  • 추가되는 데이터가 직렬화 가능.
  • API 세부 정보는 다음을 참조하세요. 캐시, DataStructure속성, 세트그룹, 꼬리표, 세트태그, 분산해시세트, NamedTags사전, setNamed태그, getDataStructuresManager, createHashSet, 이 포함되어 있습니다, getCount, 쓰기 옵션, 더하다.
  • Node.js 클라이언트 애플리케이션에 다음 모듈을 설치하고 포함시키세요.

    • 기업: ncache-클라이언트
  • 애플리케이션에 다음 클래스를 포함합니다.

    • 캐시
    • 데이터 구조 관리자
    • 꼬리표
    • NamedTags사전
  • 캐시가 실행 중이어야 합니다.
  • 추가되는 데이터가 직렬화 가능.
  • API 세부 정보는 다음을 참조하세요. 캐시, DataStructure속성, 세트그룹, NamedTags사전, 꼬리표, setNamed태그, getDataStructuresManager, 목록 작성, 이 포함되어 있습니다, getCount, 세트태그, 더하다.

다음 예제는 라는 이름의 데이터 구조에 대해 검색 가능한 속성을 구성합니다. 제품 ID 집합.NET 및 Java 예제는 HashSet을 생성하는 반면 Node.js 예제는 List를 생성합니다. 그룹화 전자태그와 명명된 태그는 다음을 사용하여 데이터 구조와 연결됩니다. DataTypeAttributes or DataStructureAttributes.

팁

데이터 구조가 생성되었는지 확인하는 빠른 방법 중 하나는 다음 중 하나의 속성을 사용하는 것입니다. Cache 수업:

  • Count 캐시에 있는 항목 수를 반환합니다.
  • Contains 데이터 구조의 지정된 키가 캐시에 존재하는지 확인합니다.
  • . NET
  • 자바
  • Node.js를
try
{
  // Precondition: Cache is already connected

  // Specify unique cache key for set
  string key = "ProductIDSet";

  // Specify attributes for HashSet
  var attributes = new DataTypeAttributes();

  // Specify group "Electronics"
  attributes.Group = "Electronics";

  // Specify tags
  Tag[] tags = new Tag[2];
  tags[0] = new Tag("2 Year Warranty");
  tags[1] = new Tag("Stainless Steel");
  attributes.Tags = tags;

  // Specify Named Tag
  var namedTag = new NamedTagsDictionary();
  namedTag.Add("Discount", 0.4);
  attributes.NamedTags = namedTag;

  // Create HashSet with attributes
  IDistributedHashSet<int> hashSet = cache.DataTypeManager.CreateHashSet<int>(key, attributes);

  // Adding Product IDs to HashSet
  int[] productIDs = FetchProductIDs();
  foreach(var productID in productIDs)
  {
      // Add product IDs to HashSet
      hashSet.Add(productID);
  }
  // You can also query on this HashSet using these attributes
}
catch (OperationFailedException ex)
{
    // NCache specific exception
    if(ex.ErrorCode == NCacheErrorCodes.KEY_ALREADY_EXISTS)
    {
        // An item with the same key already exists
    }
    else if (ex.ErrorCode == NCacheErrorCodes.CACHEITEM_IN_DATA_STRUCTURES)
    {
        // Data structures cannot be of CacheItem type
        // CacheItems cannot be added in data structures
    }
    else
    {
        // NCache specific exception
        // Exception can occur due to:
        // Connection Failures
        // Operation Timeout
        // Operation performed during state transfer
    }
}
catch (Exception ex)
{
    // Any generic exception like ArgumentNullException or ArgumentException
}
try
{
  // Precondition: Cache is already connected

  // Specify unique cache key for set
  String key = "ProductIDSet";

  // Specify attributes for HashSet
  var attributes = new DataStructureAttributes();

  // Specify group "Electronics"
  attributes.setGroup("Electronics");

  // Specify tags
  Tag[] tags = new Tag[2];
  tags[0] = new Tag("2 Year Warranty");
  tags[1] = new Tag("Stainless Steel");
  attributes.setTags(Arrays.asList(tags));

  // Specify Named Tag
  var namedTag = new NamedTagsDictionary();
  namedTag.add("Discount", 0.4);
  attributes.setNamedTags(namedTag);
  WriteThruOptions writeThruOptions = null;

  // Create HashSet with attributes
  DistributedHashSet hashSet = cache.getDataStructuresManager().createHashSet(key, attributes, writeThruOptions, Integer.class);

  // Adding Product IDs to HashSet
  int[] productIDs = fetchProductIDs();
  for (var productID : productIDs) {
      // Add product IDs to HashSet
      hashSet.add(productID);
  }
  // You can query on this HashSet using these attributes
}
catch (OperationFailedException ex) 
{
    // NCache specific exception
    if (ex.getErrorCode() == NCacheErrorCodes.KEY_ALREADY_EXISTS) {
        // An item with the same key already exists
    } else if (ex.getErrorCode() == NCacheErrorCodes.CACHEITEM_IN_DATA_STRUCTURES) {
        // Data structures cannot be of CacheItem type
        // CacheItems cannot be added in data structures
    } else {
        // NCache specific exception
        // 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
  // This is an async method

  // Specify unique cache key for list
  var key = "ProductIDSet";

  // Specify attributes for list
  var attributes = new ncache.DataStructureAttributes();

  // Specify group "Electronics"
  attributes.setGroup("Electronics");

  // Specify tags
  var tags = [
  new ncache.Tag("2 Year Warranty"),
  new ncache.Tag("Stainless Steel"),
  ];
  attributes.setTags(tags);

  // Specify Named Tag
  var namedTag = new ncache.NamedTagsDictionary();
  namedTag.add("Discount", 0.4);
  attributes.setNamedTags(namedTag);

  // Create list with attributes
  var list = await (
  await this.cache.getDataStructuresManager()
  ).createList(key, Number(), attributes, null);

  // Adding Product IDs to list
  var productIDs = this.fetchProductIDs();
  for (var productID in productIDs) {
  // Add product IDs to list
  list.add(productID);
  }
  // You can query on this list using these attributes
}
catch (error) {
  // Handle errors
}
주의 사항

작업이 오류로부터 안전한지 확인하려면 에 설명된 대로 애플리케이션 내에서 잠재적인 예외를 처리하는 것이 좋습니다. 처리 실패.

추가 자료

NCache 데이터 구조로 검색 가능한 속성을 구성하기 위한 샘플 애플리케이션을 제공합니다. GitHub의.

도 참조

.그물: Alachisoft.NCache.클라이언트.데이터 유형 네임 스페이스
자바 : com.alachisoft.ncache.client.데이터 구조 네임 스페이스
Node.js : 데이터 구조 관리자 수업

문의하기

전화

+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.의 등록상표입니다.
맨 위로