Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

423
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda