All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.cache.infinispan.access.TombstoneSynchronization Maven / Gradle / Ivy

There is a newer version: 5.6.15.Final
Show newest version
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.cache.infinispan.access;

import org.hibernate.cache.infinispan.impl.BaseTransactionalDataRegion;
import org.hibernate.cache.infinispan.util.InvocationAfterCompletion;
import org.hibernate.cache.infinispan.util.Tombstone;
import org.hibernate.resource.transaction.TransactionCoordinator;
import org.infinispan.AdvancedCache;

import java.util.UUID;
import java.util.concurrent.TimeUnit;

/**
 * @author Radim Vansa <[email protected]>
 */
public class TombstoneSynchronization extends InvocationAfterCompletion {
	private final UUID uuid = UUID.randomUUID();
	private final BaseTransactionalDataRegion region;
	private final K key;

	public TombstoneSynchronization(TransactionCoordinator tc, AdvancedCache cache, boolean requiresTransaction, BaseTransactionalDataRegion region, K key) {
		super(tc, cache, requiresTransaction);
		this.key = key;
		this.region = region;
	}

	public UUID getUuid() {
		return uuid;
	}

	public K getKey() {
		return key;
	}

	@Override
	public void beforeCompletion() {
	}

	@Override
	public void invoke(boolean success, AdvancedCache cache) {
		Tombstone tombstone = new Tombstone(uuid, region.nextTimestamp(), true);
		cache.put(key, tombstone, region.getTombstoneExpiration(), TimeUnit.MILLISECONDS);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy