0

Trying to use memcache's increment function in VB.NET. It won't increment a darn thing and returns -1 as the result when trying to use the increment function. Always says message counter incremented from 1. Value is now 1

Here's my sub as it stands. First run it adds, then subsequent runs it should use increment and print the value to screen.

    Dim msgCounter As String
    Dim cacheKey As String = "testkey01"
    msgCounter = DistCache.Get(cacheKey)
    If String.IsNullOrEmpty(msgCounter) Then
        DistCache.Add(cacheKey, 1, TimeSpan.FromMinutes(5))
        msgCounter = "message counter was 0"
    Else
        Label2.Text = DistCache.Increment(cacheKey, 1)
        msgCounter = "message counter incremented from " & msgCounter & ". Value is now " & DistCache.Get(cacheKey)
    End If
    lab1.Text = msgCounter
Ry-
  • 218,210
  • 55
  • 464
  • 476
g179mm
  • 13
  • 3

1 Answers1

1

The data type of the increment object must be string.

the correct line: DistCache.Add(cacheKey, "1", TimeSpan.FromMinutes(5))

Marek Grzenkowicz
  • 17,024
  • 9
  • 81
  • 111
metro
  • 26
  • 1