@@ -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,46 @@ 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+
90+ tpl .FieldCount = 21
91+ mCache .insert (tpl .TemplateID , ip , tpl , 514 )
92+
93+ v , ok := mCache .retrieve (tpl .TemplateID , ip , 513 )
94+
95+ if ! ok {
96+ t .Error ("expected mCache retrieve status true, got" , ok )
97+ }
98+ if v .FieldCount != 19 {
99+ t .Error ("expected template id#:310 with Field count#:19, got" , v .TemplateID , v .FieldCount )
100+ }
101+
102+ v , ok = mCache .retrieve (tpl .TemplateID , ip , 514 )
103+
104+ if ! ok {
105+ t .Error ("expected mCache retrieve status true, got" , ok )
106+ }
107+ if v .FieldCount != 21 {
108+ t .Error ("expected template id#:310 with Field count#:21, got" , v .TemplateID , v .FieldCount )
109+ }
110+ }
0 commit comments