플랫폼 캐시

dev_jo·2022년 6월 7일
0

세일즈포스

목록 보기
4/18

1. 캐시 사용의 이점

  • 캐시가 API 호출로 데이터 검색 하는 속도 보다 훨씬 빠르다.
  • 앱 성능이 향상된다.

2. HOW TO USE?

먼저 ORG에 플랫폼 캐시를 등록해야 한다.
1. ORG 셋업에서 PLATFORM CACHE 메뉴 클릭
2. New Platform Cache Partition 버튼 클릭
3. 이름, 라벨, 사용할 캐시 수 작성 및 저장


3. 코드 예제 (캐시 저장)

public without sharing class cacheController {
  public static void register () {
      Cache.OrgPartition orgPart = Cache.Org.getPartition('local.nameSample'); 
      // Add cache value to the partition. Usually, the value is obtained from a 
      // callout, but hardcoding it in this example for simplicity.
      orgPart.put('DollarToEuroRate', '0.91'); // 캐시 저장. 
      // Retrieve cache value from the partition
      String cachedRate = (String)orgPart.get('DollarToEuroRate');

      System.debug('DollarToEuroRate :: ' + orgPart.get('DollarToEuroRate'));

	}
}

캐시 라이브러리
https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_cache.htm

profile
To be a better developer!!

0개의 댓글