Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

424
Vistas
What‘s different between weakKeys() and weakValues() in Guava Cache?

I know weakKeys() means the keys are wrapped by WeakReference and GC may collect the keys automatically, same with weakValues()(for value).

My understanding: Once an entry (whether key or value) was collected by GC, the entry is expired.

My question:

  • Are weakKeys() and weakValues() equivalent? (one of them was collected, the entry is expired)
  • Guava doc said: "when this method is used, the resulting cache will use identity (==) comparison to determine equality of values". When the cache compares the value? for what?
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Are weakKeys() and weakValues() equivalent? (one of them was collected, the entry is expired)

No, if a key or value is collected, the Entry itself will not expire. You will still have access to the Entry, but the "reference" to the key and value will point you to null.

Guava doc said: "when this method is used, the resulting cache will use identity (==) comparison to determine equality of values". When the cache compares the value? for what?

In Java, Object variables are basically pointers, which means they store an 8-bit address in the memory block containing the object. So, the documentation says that it will not compare objects (because they are null), but references to objects.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda