@@ -33,7 +33,7 @@ func TestMemCacheRetrieve(t *testing.T) {
3333 mCache := GetCache ("cache.file" )
3434 d := NewDecoder (ip , tpl )
3535 d .Decode (mCache )
36- v , ok := mCache .retrieve (256 , ip )
36+ v , ok := mCache .retrieve (256 , ip , 33792 )
3737 if ! ok {
3838 t .Error ("expected mCache retrieve status true, got" , ok )
3939 }
@@ -48,9 +48,9 @@ func TestMemCacheInsert(t *testing.T) {
4848 mCache := GetCache ("cache.file" )
4949
5050 tpl .TemplateID = 310
51- mCache .insert (310 , ip , tpl )
51+ mCache .insert (310 , ip , tpl , 513 )
5252
53- v , ok := mCache .retrieve (310 , ip )
53+ v , ok := mCache .retrieve (310 , ip , 513 )
5454 if ! ok {
5555 t .Error ("expected mCache retrieve status true, got" , ok )
5656 }
@@ -65,15 +65,45 @@ func TestMemCacheAllSetIds(t *testing.T) {
6565 mCache := GetCache ("cache.file" )
6666
6767 tpl .TemplateID = 310
68- mCache .insert (tpl .TemplateID , ip , tpl )
68+ mCache .insert (tpl .TemplateID , ip , tpl , 513 )
6969 tpl .TemplateID = 410
70- mCache .insert (tpl .TemplateID , ip , tpl )
70+ mCache .insert (tpl .TemplateID , ip , tpl , 513 )
7171 tpl .TemplateID = 210
72- mCache .insert (tpl .TemplateID , ip , tpl )
72+ mCache .insert (tpl .TemplateID , ip , tpl , 513 )
7373
7474 expected := []int {210 , 310 , 410 }
7575 actual := mCache .allSetIds ()
7676 if ! reflect .DeepEqual (expected , actual ) {
7777 t .Errorf ("Expected set IDs %v, got %v" , expected , actual )
7878 }
7979}
80+
81+ func TestMemCache_keyWithDifferentDomainIDs (t * testing.T ) {
82+ var tpl TemplateRecord
83+ ip := net .ParseIP ("127.0.0.1" )
84+ mCache := GetCache ("cache.file" )
85+
86+ tpl .TemplateID = 310
87+ tpl .FieldCount = 19
88+ mCache .insert (tpl .TemplateID , ip , tpl , 513 )
89+ tpl .FieldCount = 21
90+ mCache .insert (tpl .TemplateID , ip , tpl , 514 )
91+
92+ v , ok := mCache .retrieve (tpl .TemplateID , ip , 513 )
93+
94+ if ! ok {
95+ t .Error ("expected mCache retrieve status true, got" , ok )
96+ }
97+ if v .FieldCount != 19 {
98+ t .Error ("expected template id#:310 with Field count#:19, got" , v .TemplateID , v .FieldCount )
99+ }
100+
101+ v , ok = mCache .retrieve (tpl .TemplateID , ip , 514 )
102+
103+ if ! ok {
104+ t .Error ("expected mCache retrieve status true, got" , ok )
105+ }
106+ if v .FieldCount != 21 {
107+ t .Error ("expected template id#:310 with Field count#:21, got" , v .TemplateID , v .FieldCount )
108+ }
109+ }
0 commit comments