This project is read-only.

Objects in memcached is read-only?

Jun 2, 2010 at 3:05 AM

 <Serializable()> Public Class CTestMemcache
    Public TestID As String = ""
    Public Items  As New List(Of String)
End Class

'Add memcached
Dim oTest As New CTestMemcache()
oTest .TestID = "_Test_Memcached"
oTest .Items .AddRange("A;B;C;D".Split(";"c))

 DistCache.Add("__TEST_MEMCACHED", oTest)

'Update memcached
Dim oTest As CTestMemcache = Nothing

If  DistCache.Get("__TEST_MEMCACHED") IsNot Nothing Then
    oTest  = CType(DistCache.Get("__TEST_MEMCACHED"), CTestMemcache)
    oTest = New CTestMemcache()
    oTest .TestID = "_Test_Memcached"
     DistCache.Add("__TEST_MEMCACHED", oTest)
End IF

oTest .Items .AddRange("E;F;G;H".Split(";"c))    

'Use memcached
Dim oTest As CTestMemcache =  CType(DistCache.Get("__TEST_MEMCACHED"), CTestMemcache)
display value oTest.Items but it display A;B;C;D isnot E;F;G;H

-> why?  objects in memcached is read-only?  if i use HttpContext.Current.Cache, it's will be change E;F;G;H

Jun 2, 2010 at 5:05 PM

Item in memcached are not readonly. They can be updated. For memcached, objects are serialized and send back and forth on tcp connection while cache is an in-process cache and nothing like this is involved.
So this line of code

oTest .Items .AddRange("E;F;G;H".Split(";"c))  

is actually updating the local copy. You will have set is again to memcached.

Hope this helps,
- Fahad