property-ttl

WebJar for property-ttl

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

property-ttl
Последняя версия

Последняя версия

1.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

property-ttl
WebJar for property-ttl
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/soldair/property-ttl

Скачать property-ttl

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/property-ttl/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>property-ttl</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/property-ttl/
implementation 'org.webjars.npm:property-ttl:1.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/property-ttl/
implementation ("org.webjars.npm:property-ttl:1.0.0")
'org.webjars.npm:property-ttl:jar:1.0.0'
<dependency org="org.webjars.npm" name="property-ttl" rev="1.0.0">
  <artifact name="property-ttl" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='property-ttl', version='1.0.0')
)
libraryDependencies += "org.webjars.npm" % "property-ttl" % "1.0.0"
[org.webjars.npm/property-ttl "1.0.0"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

property-ttl

null out a property after ttl if it has not been accessed.

if you have a case where something makes large data objects but you can't or don't want to hold them all in memory all the time. This allows you to null out those propertys if they are not being used.

var cleanup = require('property-ttl')

var registry = {
  getData:function(){
    if(!data) this.data = generateOodlesOfData()
    return this.data
  },
  data:null
}

// every 2000 ms of inactivity clear this property out.
cleanup(registry,'data',2000)

doActionWithData(registry.getData())

// `registry.data === null` === false
setTimeout(function(){
  // `registry.data === null` === true
},2010)

After 2000 ms the property is nulled out agian freeing up that memory for handling other kinds of server requests. If the peoperty was accessed every 1500 ms it would never be cleared because the ttl will keep extending on each access.

api

  • var cleanup = require('process-ttl')

  • cleanup(object, property, ttl, ongc)

    • object, the object that owns the property
    • property, the property name you want to manage. it need not be defined.
    • ttl, the time in ms you want an inactive property to hang around.
    • ongc(timeLived), OPTIONAL the ongc callback fires each time a property is gced.
  • cleanup.defaultValue === null

    • this property changes the module default value for cleared peoperties, default null

Версии библиотеки

Версия
1.0.0