mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
Add remove method to StateProviderInterface
This commit is contained in:
@ -90,4 +90,15 @@ public class InMemoryStateProvider implements StateProviderInterface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Remove a block of data, under a key, from the state store.
|
||||
*******************************************************************************/
|
||||
@Override
|
||||
public void remove(AbstractStateKey key)
|
||||
{
|
||||
map.remove(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,4 +52,10 @@ public interface StateProviderInterface
|
||||
** Get a block of data, under a key, from the state store.
|
||||
*******************************************************************************/
|
||||
<T extends Serializable> Optional<T> get(Class<? extends T> type, AbstractStateKey key);
|
||||
|
||||
/*******************************************************************************
|
||||
** Remove a block of data, under a key, from the state store.
|
||||
*******************************************************************************/
|
||||
void remove(AbstractStateKey key);
|
||||
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import java.util.Optional;
|
||||
import com.kingsrook.qqq.backend.core.logging.QLogger;
|
||||
import com.kingsrook.qqq.backend.core.utils.JsonUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import static com.kingsrook.qqq.backend.core.logging.LogUtils.logPair;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -110,6 +111,21 @@ public class TempFileStateProvider implements StateProviderInterface
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Remove a block of data, under a key, from the state store.
|
||||
*******************************************************************************/
|
||||
@Override
|
||||
public void remove(AbstractStateKey key)
|
||||
{
|
||||
File file = getFile(key);
|
||||
if(!file.delete())
|
||||
{
|
||||
LOG.warn("Error deleting state-providing tempFile", logPair("file", file.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Get the file referenced by a key
|
||||
*******************************************************************************/
|
||||
|
Reference in New Issue
Block a user