Skip to content

Commit

Permalink
Updated references. Moved go to 1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
seroukhov committed Apr 6, 2021
1 parent 1008334 commit 4842dfa
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 80 deletions.
31 changes: 31 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Go Main",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${workspaceRoot}",
"env": {},
"args": [],
"showLog": true
},
{
"name": "Go Test",
"type": "go",
"request": "launch",
"mode": "test",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${file}",
"env": {},
"args": [],
"showLog": true
}
]
}
23 changes: 17 additions & 6 deletions cache/MemcachedCache.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,23 @@ func (c *MemcachedCache) Store(correlationId string, key string, value interface
return nil, err
}
timeoutInSec := int32(timeout) / 1000
val, ok := value.([]byte)
if !ok {
val, err = json.Marshal(value)
if err != nil {
return nil, err
}

var val []byte

switch v := value.(type) {
case []byte:
val = v
break
case string:
val, err = json.Marshal(v)
break
default:
val, err = json.Marshal(v)
break
}

if err != nil {
return nil, err
}

item := memcache.Item{
Expand Down
13 changes: 0 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,7 @@ go 1.16

require (
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b
<<<<<<< HEAD
github.com/pip-services3-go/pip-services3-commons-go v1.1.0
github.com/pip-services3-go/pip-services3-components-go v1.1.0
github.com/stretchr/testify v1.7.0
=======
github.com/creack/pty v1.1.11 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/pip-services3-go/pip-services3-commons-go v1.0.3
github.com/pip-services3-go/pip-services3-components-go v1.0.6
github.com/pip-services3-go/pip-services3-redis-go v1.0.0 // indirect
github.com/stretchr/objx v0.3.0 // indirect
github.com/stretchr/testify v1.7.0
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
>>>>>>> b9cd81a4ed19d1ae032e77f19eeb3ed9c00359c2
)
50 changes: 0 additions & 50 deletions go.sum

This file was deleted.

17 changes: 6 additions & 11 deletions test/fixture/CacheFixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ func (c *CacheFixture) TestStoreAndRetrieve(t *testing.T) {
assert.Equal(t, VALUE1, val)

var str string
ok, err := c.cache.RetrieveAs("", KEY2, &str)
assert.True(t, ok)
result, err := c.cache.RetrieveAs("", KEY2, &str)
assert.NotNil(t, result)
assert.Nil(t, err)
assert.Equal(t, VALUE2, str)

}

func (c *CacheFixture) TestRetrieveExpired(t *testing.T) {
Expand All @@ -65,15 +64,12 @@ func (c *CacheFixture) TestRetrieveExpired(t *testing.T) {
assert.Nil(t, val)

var str string
ok, err := c.cache.RetrieveAs("", KEY1, &str)
assert.False(t, ok)
result, err := c.cache.RetrieveAs("", KEY1, &str)
assert.Nil(t, result)
assert.Nil(t, err)
assert.Equal(t, str, "")

}

func (c *CacheFixture) TestRemove(t *testing.T) {

_, err := c.cache.Store("", KEY1, VALUE1, 1000)
assert.Nil(t, err)

Expand All @@ -85,8 +81,7 @@ func (c *CacheFixture) TestRemove(t *testing.T) {
assert.Nil(t, val)

var str string
ok, err := c.cache.RetrieveAs("", KEY1, &str)
assert.False(t, ok)
result, err := c.cache.RetrieveAs("", KEY1, &str)
assert.Nil(t, result)
assert.Nil(t, err)
assert.Equal(t, str, "")
}

0 comments on commit 4842dfa

Please sign in to comment.