더북(TheBook)

고객 데이터에 접근하는 프로그램은 일반적으로 먼저 캐시를 확인하고 캐시에 데이터가 없으면 데이터베이스를 뒤져볼 것이다. 다음은 getCustomer 함수에 대한 의사擬似 코드 예시다.


define getCustomer(p_customerID):
  begin
     if exists(customerCache[‘1982737:firstName]),
           return(
              customerCache[p_customerID+’:lastname’],
              customerCache[p_customerID+’:shippingAddress’],
              customerCache[p_customerID+’:shippingCity’],
              customerCache[’p_customerID+‘:shippingState’],
            customerCache[p_customerID+:shippingZip’]
              ); 
    else
           return(addQueryResultsToCache(p_customerID,
SELECT
               firstName,
               lastName,
               shippingAddress,
               shippingCity,
               shippingState,
               shippingZip
            FROM
               customers
            WHERE
               customerID = p_customerID)
  end;
);

신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.