|
|
@ -78,8 +78,8 @@ func TestGenCacheKeys(t *testing.T) {
|
|
|
|
assert.Equal(t, true, func() bool {
|
|
|
|
assert.Equal(t, true, func() bool {
|
|
|
|
return cacheKeyEqual(primariCacheKey, Key{
|
|
|
|
return cacheKeyEqual(primariCacheKey, Key{
|
|
|
|
VarLeft: "cacheUserIdPrefix",
|
|
|
|
VarLeft: "cacheUserIdPrefix",
|
|
|
|
VarRight: `"cache#user#id#"`,
|
|
|
|
VarRight: `"cache:user:id:"`,
|
|
|
|
VarExpression: `cacheUserIdPrefix = "cache#user#id#"`,
|
|
|
|
VarExpression: `cacheUserIdPrefix = "cache:user:id:"`,
|
|
|
|
KeyLeft: "userIdKey",
|
|
|
|
KeyLeft: "userIdKey",
|
|
|
|
KeyRight: `fmt.Sprintf("%s%v", cacheUserIdPrefix, id)`,
|
|
|
|
KeyRight: `fmt.Sprintf("%s%v", cacheUserIdPrefix, id)`,
|
|
|
|
DataKeyRight: `fmt.Sprintf("%s%v", cacheUserIdPrefix, data.Id)`,
|
|
|
|
DataKeyRight: `fmt.Sprintf("%s%v", cacheUserIdPrefix, data.Id)`,
|
|
|
@ -95,19 +95,19 @@ func TestGenCacheKeys(t *testing.T) {
|
|
|
|
expected := []Key{
|
|
|
|
expected := []Key{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
VarLeft: "cacheUserClassNamePrefix",
|
|
|
|
VarLeft: "cacheUserClassNamePrefix",
|
|
|
|
VarRight: `"cache#user#class#name#"`,
|
|
|
|
VarRight: `"cache:user:class:name:"`,
|
|
|
|
VarExpression: `cacheUserClassNamePrefix = "cache#user#class#name#"`,
|
|
|
|
VarExpression: `cacheUserClassNamePrefix = "cache:user:class:name:"`,
|
|
|
|
KeyLeft: "userClassNameKey",
|
|
|
|
KeyLeft: "userClassNameKey",
|
|
|
|
KeyRight: `fmt.Sprintf("%s%v%v", cacheUserClassNamePrefix, class, name)`,
|
|
|
|
KeyRight: `fmt.Sprintf("%s%v:%v", cacheUserClassNamePrefix, class, name)`,
|
|
|
|
DataKeyRight: `fmt.Sprintf("%s%v%v", cacheUserClassNamePrefix, data.Class, data.Name)`,
|
|
|
|
DataKeyRight: `fmt.Sprintf("%s%v:%v", cacheUserClassNamePrefix, data.Class, data.Name)`,
|
|
|
|
KeyExpression: `userClassNameKey := fmt.Sprintf("%s%v%v", cacheUserClassNamePrefix, class, name)`,
|
|
|
|
KeyExpression: `userClassNameKey := fmt.Sprintf("%s%v:%v", cacheUserClassNamePrefix, class, name)`,
|
|
|
|
DataKeyExpression: `userClassNameKey := fmt.Sprintf("%s%v%v", cacheUserClassNamePrefix, data.Class, data.Name)`,
|
|
|
|
DataKeyExpression: `userClassNameKey := fmt.Sprintf("%s%v:%v", cacheUserClassNamePrefix, data.Class, data.Name)`,
|
|
|
|
FieldNameJoin: []string{"class", "name"},
|
|
|
|
FieldNameJoin: []string{"class", "name"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
VarLeft: "cacheUserMobilePrefix",
|
|
|
|
VarLeft: "cacheUserMobilePrefix",
|
|
|
|
VarRight: `"cache#user#mobile#"`,
|
|
|
|
VarRight: `"cache:user:mobile:"`,
|
|
|
|
VarExpression: `cacheUserMobilePrefix = "cache#user#mobile#"`,
|
|
|
|
VarExpression: `cacheUserMobilePrefix = "cache:user:mobile:"`,
|
|
|
|
KeyLeft: "userMobileKey",
|
|
|
|
KeyLeft: "userMobileKey",
|
|
|
|
KeyRight: `fmt.Sprintf("%s%v", cacheUserMobilePrefix, mobile)`,
|
|
|
|
KeyRight: `fmt.Sprintf("%s%v", cacheUserMobilePrefix, mobile)`,
|
|
|
|
DataKeyRight: `fmt.Sprintf("%s%v", cacheUserMobilePrefix, data.Mobile)`,
|
|
|
|
DataKeyRight: `fmt.Sprintf("%s%v", cacheUserMobilePrefix, data.Mobile)`,
|
|
|
|