Remove phantom copy of expiring data when source gets persisted.
This commit makes sure to clean up resources when a previously expiring entity is persisted by setting the time to live to zero or negative. In case a phantom copy exists for the changed entity, it is removed to free space on the server and prevent expiration events from being sent. Closes #1955 Original Pull Request: #1961
This commit is contained in:
committed by
Christoph Strobl
parent
febdb82e58
commit
e46246721f
@@ -99,6 +99,7 @@ import org.springframework.util.ObjectUtils;
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @author Andrey Muchnik
|
||||
* @since 1.7
|
||||
*/
|
||||
public class RedisKeyValueAdapter extends AbstractKeyValueAdapter
|
||||
@@ -248,6 +249,11 @@ public class RedisKeyValueAdapter extends AbstractKeyValueAdapter
|
||||
}
|
||||
}
|
||||
|
||||
boolean isNoExpire = rdo.getTimeToLive() == null || rdo.getTimeToLive() != null && rdo.getTimeToLive() < 0;
|
||||
if (isNoExpire && !isNew && keepShadowCopy()){
|
||||
connection.del(ByteUtils.concat(objectKey, BinaryKeyspaceIdentifier.PHANTOM_SUFFIX));
|
||||
}
|
||||
|
||||
connection.sAdd(toBytes(rdo.getKeyspace()), key);
|
||||
|
||||
IndexWriter indexWriter = new IndexWriter(connection, converter);
|
||||
@@ -492,7 +498,7 @@ public class RedisKeyValueAdapter extends AbstractKeyValueAdapter
|
||||
} else {
|
||||
|
||||
connection.persist(redisKey);
|
||||
connection.persist(ByteUtils.concat(redisKey, BinaryKeyspaceIdentifier.PHANTOM_SUFFIX));
|
||||
connection.del(ByteUtils.concat(redisKey, BinaryKeyspaceIdentifier.PHANTOM_SUFFIX));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user