Skip to content

Latest commit

 

History

History
56 lines (39 loc) · 1.6 KB

inMemoryExpirer.md

File metadata and controls

56 lines (39 loc) · 1.6 KB

InMemoryExpirer

Near realtime expiry handler

queue Structure: { time1: [{key: key1, onExpire: () => {}}, {key: key2, onExpire: () => {}}], time2: [{key: key3, onExpire: () => {}}] }

Kind: global class

inMemoryExpirer.expire

Expiry function

Kind: instance property of InMemoryExpirer

inMemoryExpirer.add(time, key, onExpire)

Add to expiry queue

Kind: instance method of InMemoryExpirer

Param Type Description
time Number When to expire
key String key to store expiry data against
onExpire function Expiry callback, called when Date.now() ~= time

inMemoryExpirer.remove(time, key)

Remove specific key from expiry queue

Kind: instance method of InMemoryExpirer

Param Type Description
time Number Expiry time
key String key to remove from the expiry queue

inMemoryExpirer.dispose()

Cleanup - Empty queue & clear expirer timer

Kind: instance method of InMemoryExpirer