Classes
- WeakMapStorage
A specialization of the
MapStorage
storage mimicking the nativeWeakMap
using its internal garbage collector used once the size of the storage reaches the configured threshold.- WeakRef
A simple reference wrapper that emulates a weak reference. We seem to have no other option, since WeakMap and WeakSet are not enumerable (so what is the point of WeakMap and WeakSet if you still need to manage the keys?!) and there is no native way to create a weak reference.
WeakMapStorage
A specialization of the MapStorage
storage mimicking the native
WeakMap
using its internal garbage collector used once the size of
the storage reaches the configured threshold.
Kind: global class
new WeakMapStorage(config)
Initializes the storage.
Param | Type | Description |
---|---|---|
config | Object |
Weak map storage configuration. The fields have the following meaning: - entryTtl The time-to-live of a storage entry in milliseconds. |
weakMapStorage._entryTtl : number
The time-to-live of a storage entry in milliseconds.
Kind: instance property of WeakMapStorage
weakMapStorage.has()
Kind: instance method of WeakMapStorage
weakMapStorage.get()
Kind: instance method of WeakMapStorage
weakMapStorage.set()
Kind: instance method of WeakMapStorage
weakMapStorage.delete()
Kind: instance method of WeakMapStorage
weakMapStorage.keys()
Kind: instance method of WeakMapStorage
weakMapStorage.size()
Kind: instance method of WeakMapStorage
weakMapStorage._discardExpiredEntries()
Deletes all expired entries from this storage.
Kind: instance method of WeakMapStorage
WeakRef
A simple reference wrapper that emulates a weak reference. We seem to have no other option, since WeakMap and WeakSet are not enumerable (so what is the point of WeakMap and WeakSet if you still need to manage the keys?!) and there is no native way to create a weak reference.
Kind: global class
- WeakRef
- new WeakRef(target, ttl)
- ._reference :
Object
- ._expiration :
number
- .target ⇒
Object
new WeakRef(target, ttl)
Initializes the weak reference to the target reference.
Param | Type | Description |
---|---|---|
target | Object |
The target reference that should be referenced by this weak reference. |
ttl | number |
The maximum number of milliseconds the weak reference should be kept. The reference will be discarded once ACCESSED after the specified timeout. |
weakRef._reference : Object
The actual target reference, or null
if the reference has
been already discarded.
Kind: instance property of WeakRef
weakRef._expiration : number
The UNIX timestamp with millisecond precision marking the moment at or after which the reference will be discarded.
Kind: instance property of WeakRef
weakRef.target ⇒ Object
Returns the target reference, provided that the target reference is
still alive. Returns null
if the reference has been discarded.
Kind: instance property of WeakRef
Returns: Object
- The target reference, or null
if the reference
has been discarded by the garbage collector.