0
votes

I have a list which is contains 10500 of objects. When I tried to put it in the cache this made an exeption. Then I decreased the list objects number to 9000, then the cache worked fine.

So can anyone please tell me how to store all of that list in the cache??

below is the dataCacheClient in my web.config :

<dataCacheClient requestTimeout="600000" 
                  channelOpenTimeout="12000" 
                  maxConnectionsToServer="1">
<hosts>
  <host name="Platform.Almanhal.local" cachePort="22233" />
</hosts>

<transportProperties connectionBufferSize="131072" 
                     maxBufferPoolSize="568435456"
                     maxBufferSize="183886080" 
                     maxOutputDelay="2" 
                     channelInitializationTimeout="60000" />
</dataCacheClient>

and the below is the appfabric api I used to store this list :

public T Data<T>(string cacheKey, int expirationSeconds, Func<T> method)
    {
        T data = default(T);
        try
        {
            string key = GetEncryptedKey(cacheKey);
            var cache = GetFromCache(key);

            data = cache == null ? default(T) : (T)cache;
            if (data == null)
            {
                data = method();
                if (expirationSeconds > 0 && data != null)
                {
                    lock (sync)
                    {
                        PutInCache(key, data, TimeSpan.FromSeconds(expirationSeconds));
                    }
                }
                Logger.LogInfo(string.Format("{0} Loaded From DB", typeof(T).GetProperties()[2].PropertyType.Name));
            }
            else
            {
                Logger.LogInfo(string.Format("{0} Loaded From Cache", typeof(T).GetProperties()[2].PropertyType.Name));
            }
        }
        catch (Exception ex)
        {
            Logger.LogInfo(ex.InnerException.Message);
        }
        return data;
    }

The PutInCache function is below :

 public void PutInCache(string key, object obj, TimeSpan tspan)
    {
        //TracingLibrary.TraceEvents.AddEvent("Inside Put in Cache");
        try
        {
            _cache.Put(key, obj, tspan);
        }
        catch (Exception e)
        {
            string msg = e.InnerException.ToString();
            Logger.LogInfo(string.Format("Cannot put object in cache {0}, \nException: {1} \nMessage:{2}", key, e.InnerException.ToNullOrString(), e.Message.ToNullOrString()));
            //write to logger ("Exception putting in cache", e.InnerException);
        }
    }

And this is the exeption message :

ErrorCode:SubStatus:There is a temporary failure. Please retry later. (One or more specified cache servers are unavailable, which could be caused by busy network or servers. For on-premises cache clusters, also verify the following conditions. Ensure that security permission has been granted for this client account, and check that the AppFabric Caching Service is allowed through the firewall on all cache hosts. Also the MaxBufferSize on the server must be greater than or equal to the serialized object size sent from the client.)

1

1 Answers

0
votes

The answer is in the error message:

the MaxBufferSize on the server must be greater than or equal to the serialized object size sent from the client

You set this in the advancedProperties section of the cluster config:

<advancedProperties>      
    <transportProperties maxBufferSize="183886080" />
</advancedProperties>