0

I have been reviewing the infinispan documentation and overloaded put method returns the value being replaced, or null if nothing is being replaced.

I am using overloaded put method with nodejs and it's not returning expected data, getting undefined.

how can I achieve this with nodejs?

Looked at the documentation, need assistance to understand the behavior with Nodejs

Documentation Link : https://docs.jboss.org/infinispan/9.2/apidocs/org/infinispan/commons/api/BasicCache.html#put-K-V-

V put(K key,
  V value,
  long lifespan,
  TimeUnit unit)

An overloaded form of put(Object, Object), which takes in lifespan parameters.

Parameters:

  • key - key to use
  • value - value to store
  • lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
  • unit - unit of measurement for the lifespan

Returns:

  • the value being replaced, or null if nothing is being replaced.

Looked at the documentation, need assistance to understand the behavior with Nodejs

tom redfern
  • 30,562
  • 14
  • 91
  • 126

1 Answers1

1

From https://github.com/infinispan/js-client/blob/main/lib/infinispan.js#L327 it looks like put's third argument opts can have property previous that makes it return the old value, so try:

const oldValue = client.put('key', 'value', { previous: true })
Radim Vansa
  • 5,686
  • 2
  • 25
  • 40