2014-04-09 2 views
0

ServiceStack.Redis를 사용하기 시작했습니다. 개별 키/값을 캐시에 넣고 캐시에서 가져올 수 있습니다. 그러나 모든 항목 또는 캐시의 항목 수를 얻을 수 없습니다.ServiceStack.Redis를 사용하여 항목 및 개수 얻기 IRedisTypedClient

은 여기 CustomerEntity 클래스에서 코드

using (RedisClient cacheClient = new RedisClient(cacheServer)) 
{ 
    IRedisTypedClient<CustomerEntity> customerCache = cacheClient.As<CustomerEntity>(); 
    customer = bl.FetchCustomer(customerId); 
    //cache for two minutes 
    customerCache.SetEntry(customerId, customer, new TimeSpan(0, 2, 0)); 

    //These all show the count as 0 
    logger.Debug(customerCache.GetAll().Count); 
    logger.Debug(cacheClient.GetAll<CustomerEntity>().Count); 

    var customers = customerCache.GetAll(); 
    logger.Debug("{0} customers in the cache", customers.Count); 
} 

답변

0

이다 : 나는 레디 스 때 액세스 할 수없는 것 같아요

public string strManufacturer { get; set; } 

로 (예)

public string strManufacturer; 

교체해야 getter 및 setter가 명시 적으로 정의되어 있지 않습니다.

redis에서 C# 개체를 저장할 수 없어이 수정으로 인해 문제가 해결되었습니다. 나는이 수정 및 GETALL()을하기 전에 키를 "얻을"때 나는 레디 스 - CLI 출력

"{}" 

을 얻고 있었다. 카운트 된 상황에서 0을 반환. 프로덕션 환경에서 사용하려는 경우 ServiceStack.Redis의 사용권 조항도주의해야합니다. SO에 대한 논의는 here을 참조하십시오.

관련 문제