@@ -9,61 +9,71 @@ describe "FileSystemBlobStore", ->
99    blobStore  =  FileSystemBlobStore .load (storageDirectory)
1010
1111  it  " is empty when the file doesn't exist"  , -> 
12-     expect (blobStore .get (" foo"  )).toBeUndefined ()
13-     expect (blobStore .get (" bar"  )).toBeUndefined ()
12+     expect (blobStore .get (" foo" ,  " invalidation-key-1 "  )).toBeUndefined ()
13+     expect (blobStore .get (" bar" ,  " invalidation-key-2 "  )).toBeUndefined ()
1414
1515  it  " allows to read and write buffers from/to memory without persisting them"  , -> 
16-     blobStore .set (" foo"  , new  Buffer (" foo"  ))
17-     blobStore .set (" bar"  , new  Buffer (" bar"  ))
16+     blobStore .set (" foo"  , " invalidation-key-1 " ,  new  Buffer (" foo"  ))
17+     blobStore .set (" bar"  , " invalidation-key-2 " ,  new  Buffer (" bar"  ))
1818
19-     expect (blobStore .get (" foo"  )).toEqual (new  Buffer (" foo"  ))
20-     expect (blobStore .get (" bar"  )).toEqual (new  Buffer (" bar"  ))
19+     expect (blobStore .get (" foo"  , " invalidation-key-1"  )).toEqual (new  Buffer (" foo"  ))
20+     expect (blobStore .get (" bar"  , " invalidation-key-2"  )).toEqual (new  Buffer (" bar"  ))
21+ 
22+     expect (blobStore .get (" foo"  , " unexisting-key"  )).toBeUndefined ()
23+     expect (blobStore .get (" bar"  , " unexisting-key"  )).toBeUndefined ()
2124
2225  it  " persists buffers when saved and retrieves them on load, giving priority to in-memory ones"  , -> 
23-     blobStore .set (" foo"  , new  Buffer (" foo"  ))
24-     blobStore .set (" bar"  , new  Buffer (" bar"  ))
26+     blobStore .set (" foo"  , " invalidation-key-1 " ,  new  Buffer (" foo"  ))
27+     blobStore .set (" bar"  , " invalidation-key-2 " ,  new  Buffer (" bar"  ))
2528    blobStore .save ()
2629
2730    blobStore  =  FileSystemBlobStore .load (storageDirectory)
2831
29-     expect (blobStore .get (" foo"  )).toEqual (new  Buffer (" foo"  ))
30-     expect (blobStore .get (" bar"  )).toEqual (new  Buffer (" bar"  ))
32+     expect (blobStore .get (" foo"  , " invalidation-key-1"  )).toEqual (new  Buffer (" foo"  ))
33+     expect (blobStore .get (" bar"  , " invalidation-key-2"  )).toEqual (new  Buffer (" bar"  ))
34+     expect (blobStore .get (" foo"  , " unexisting-key"  )).toBeUndefined ()
35+     expect (blobStore .get (" bar"  , " unexisting-key"  )).toBeUndefined ()
3136
32-     blobStore .set (" foo"  , new  Buffer (" changed"  ))
37+     blobStore .set (" foo"  , " new-key " ,  new  Buffer (" changed"  ))
3338
34-     expect (blobStore .get (" foo"  )).toEqual (new  Buffer (" changed"  ))
39+     expect (blobStore .get (" foo"  , " new-key"  )).toEqual (new  Buffer (" changed"  ))
40+     expect (blobStore .get (" foo"  , " invalidation-key-1"  )).toBeUndefined ()
3541
3642  it  " persists both in-memory and previously stored buffers when saved"  , -> 
37-     blobStore .set (" foo"  , new  Buffer (" foo"  ))
38-     blobStore .set (" bar"  , new  Buffer (" bar"  ))
43+     blobStore .set (" foo"  , " invalidation-key-1 " ,  new  Buffer (" foo"  ))
44+     blobStore .set (" bar"  , " invalidation-key-2 " ,  new  Buffer (" bar"  ))
3945    blobStore .save ()
4046
4147    blobStore  =  FileSystemBlobStore .load (storageDirectory)
42-     blobStore .set (" bar"  , new  Buffer (" changed"  ))
43-     blobStore .set (" qux"  , new  Buffer (" qux"  ))
48+     blobStore .set (" bar"  , " invalidation-key-3 " ,  new  Buffer (" changed"  ))
49+     blobStore .set (" qux"  , " invalidation-key-4 " ,  new  Buffer (" qux"  ))
4450    blobStore .save ()
4551
4652    blobStore  =  FileSystemBlobStore .load (storageDirectory)
4753
48-     expect (blobStore .get (" foo"  )).toEqual (new  Buffer (" foo"  ))
49-     expect (blobStore .get (" bar"  )).toEqual (new  Buffer (" changed"  ))
50-     expect (blobStore .get (" qux"  )).toEqual (new  Buffer (" qux"  ))
54+     expect (blobStore .get (" foo"  , " invalidation-key-1"  )).toEqual (new  Buffer (" foo"  ))
55+     expect (blobStore .get (" bar"  , " invalidation-key-3"  )).toEqual (new  Buffer (" changed"  ))
56+     expect (blobStore .get (" qux"  , " invalidation-key-4"  )).toEqual (new  Buffer (" qux"  ))
57+     expect (blobStore .get (" foo"  , " unexisting-key"  )).toBeUndefined ()
58+     expect (blobStore .get (" bar"  , " invalidation-key-2"  )).toBeUndefined ()
59+     expect (blobStore .get (" qux"  , " unexisting-key"  )).toBeUndefined ()
5160
5261  it  " allows to delete keys from both memory and stored buffers"  , -> 
53-     blobStore .set (" a"  , new  Buffer (" a"  ))
54-     blobStore .set (" b"  , new  Buffer (" b"  ))
62+     blobStore .set (" a"  , " invalidation-key-1 " ,  new  Buffer (" a"  ))
63+     blobStore .set (" b"  , " invalidation-key-2 " ,  new  Buffer (" b"  ))
5564    blobStore .save ()
5665
5766    blobStore  =  FileSystemBlobStore .load (storageDirectory)
5867
59-     blobStore .set (" b"  , new  Buffer (" b"  ))
60-     blobStore .set (" c"  , new  Buffer (" c"  ))
68+     blobStore .set (" b"  , " invalidation-key-3 " ,  new  Buffer (" b"  ))
69+     blobStore .set (" c"  , " invalidation-key-4 " ,  new  Buffer (" c"  ))
6170    blobStore .delete (" b"  )
6271    blobStore .delete (" c"  )
6372    blobStore .save ()
6473
6574    blobStore  =  FileSystemBlobStore .load (storageDirectory)
6675
67-     expect (blobStore .get (" a"  )).toEqual (new  Buffer (" a"  ))
68-     expect (blobStore .get (" b"  )).toBeUndefined ()
69-     expect (blobStore .get (" c"  )).toBeUndefined ()
76+     expect (blobStore .get (" a"  , " invalidation-key-1"  )).toEqual (new  Buffer (" a"  ))
77+     expect (blobStore .get (" b"  , " invalidation-key-2"  )).toBeUndefined ()
78+     expect (blobStore .get (" b"  , " invalidation-key-3"  )).toBeUndefined ()
79+     expect (blobStore .get (" c"  , " invalidation-key-4"  )).toBeUndefined ()
0 commit comments