mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
fix: concurrent write on LRU cache (#200)
This commit is contained in:
Vendored
+33
-1
@@ -20,7 +20,31 @@ describe('LRU', () => {
|
||||
expect(lru.size).to.equal(0)
|
||||
expect(lru.read('foo')).to.be.undefined
|
||||
})
|
||||
it('should remove lrc item when full(2)', () => {
|
||||
it('should remove lrc item when full(limit=-1)', () => {
|
||||
const lru = new LRU(-1)
|
||||
lru.write('foo', 'FOO')
|
||||
lru.write('bar', 'BAR')
|
||||
expect(lru.size).to.equal(0)
|
||||
expect(lru.read('foo')).to.be.undefined
|
||||
expect(lru.read('bar')).to.be.undefined
|
||||
})
|
||||
it('should remove lrc item when full(limit=0)', () => {
|
||||
const lru = new LRU(0)
|
||||
lru.write('foo', 'FOO')
|
||||
lru.write('bar', 'BAR')
|
||||
expect(lru.size).to.equal(0)
|
||||
expect(lru.read('foo')).to.be.undefined
|
||||
expect(lru.read('bar')).to.be.undefined
|
||||
})
|
||||
it('should remove lrc item when full(limit=1)', () => {
|
||||
const lru = new LRU(1)
|
||||
lru.write('foo', 'FOO')
|
||||
lru.write('bar', 'BAR')
|
||||
expect(lru.size).to.equal(1)
|
||||
expect(lru.read('foo')).to.be.undefined
|
||||
expect(lru.read('bar')).to.equal('BAR')
|
||||
})
|
||||
it('should remove lrc item when full(limit=2)', () => {
|
||||
const lru = new LRU(2)
|
||||
expect(lru.size).to.equal(0)
|
||||
lru.write('foo', 'FOO')
|
||||
@@ -33,4 +57,12 @@ describe('LRU', () => {
|
||||
expect(lru.read('bar')).to.equal('BAR')
|
||||
expect(lru.read('coo')).to.equal('COO')
|
||||
})
|
||||
it('should overwrite item the with same key', () => {
|
||||
const lru = new LRU(2)
|
||||
lru.write('foo', 'FOO')
|
||||
expect(lru.size).to.equal(1)
|
||||
lru.write('foo', 'BAR')
|
||||
expect(lru.size).to.equal(1)
|
||||
expect(lru.read('foo')).to.equal('BAR')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user