How to use cleanup method of Support Package

Best Unobtainium_ruby code snippet using Support.cleanup

AbstractStorageService.java

Source:AbstractStorageService.java Github

copy

Full Screen

...33/**34 * Abstract base class for {@link StorageService} implementations.35 * 36 * <p>37 * The base class handles support for a background cleanup task, and handles calling of custom object serializers.38 * </p>39 */40public abstract class AbstractStorageService extends AbstractIdentifiableInitializableComponent implements41 StorageService, StorageCapabilities {42 /**43 * Number of seconds between cleanup checks. Default value: (0)44 */45 @Duration @NonNegative private long cleanupInterval;46 /** Timer used to schedule cleanup tasks. */47 private Timer cleanupTaskTimer;48 /** Timer used to schedule cleanup tasks if no external one set. */49 private Timer internalTaskTimer;50 /** Task that cleans up expired records. */51 private TimerTask cleanupTask;52 /** Configurable context size limit. */53 @Positive private int contextSize;54 /** Configurable key size limit. */55 @Positive private int keySize;56 /** Configurable value size limit. */57 @Positive private int valueSize;58 /**59 * Gets the number of milliseconds between one cleanup and another. A value of 0 indicates that no cleanup will be60 * performed.61 * 62 * @return number of milliseconds between one cleanup and another63 */64 @NonNegative @Duration public long getCleanupInterval() {65 return cleanupInterval;66 }67 /**68 * Sets the number of milliseconds between one cleanup and another. A value of 0 indicates that no cleanup will be69 * performed.70 * 71 * This setting cannot be changed after the service has been initialized.72 * 73 * @param interval number of milliseconds between one cleanup and another74 */75 @Duration public void setCleanupInterval(@Duration @NonNegative final long interval) {76 ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);77 cleanupInterval =78 Constraint.isGreaterThanOrEqual(0, interval, "Cleanup interval must be greater than or equal to zero");79 }80 /**81 * Gets the timer used to schedule cleanup tasks.82 * 83 * @return timer used to schedule cleanup tasks84 */85 @Nullable public Timer getCleanupTaskTimer() {86 return cleanupTaskTimer;87 }88 /**89 * Sets the timer used to schedule cleanup tasks.90 * 91 * This setting can not be changed after the service has been initialized.92 * 93 * @param timer timer used to schedule configuration reload tasks94 */95 public void setCleanupTaskTimer(@Nullable final Timer timer) {96 ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);97 cleanupTaskTimer = timer;98 }99 /**100 * Returns a cleanup task function to schedule for background cleanup.101 * 102 * <p>103 * The default implementation does not supply one.104 * </p>105 * 106 * @return a task object, or null107 */108 @Nullable protected TimerTask getCleanupTask() {109 return null;110 }111 /**112 * Set the context size limit.113 * 114 * @param size limit on context size in characters115 */116 public void setContextSize(@Positive final int size) {117 ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);118 contextSize = (int) Constraint.isGreaterThan(0, size, "Size must be greater than zero");119 }120 /**121 * Set the key size limit.122 * 123 * @param size size limit on key size in characters124 */125 public void setKeySize(@Positive final int size) {126 ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);127 keySize = (int) Constraint.isGreaterThan(0, size, "Size must be greater than zero");128 }129 /**130 * Set the value size limit.131 * 132 * @param size size limit on value size in characters133 */134 public void setValueSize(@Positive final int size) {135 ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);136 valueSize = (int) Constraint.isGreaterThan(0, size, "Size must be greater than zero");137 }138 /** {@inheritDoc} */139 @Override protected void doInitialize() throws ComponentInitializationException {140 super.doInitialize();141 if (cleanupInterval > 0) {142 cleanupTask = getCleanupTask();143 if (cleanupTask == null) {144 throw new ComponentInitializationException("Cleanup task cannot be null if cleanupInterval is set.");145 } else if (cleanupTaskTimer == null) {146 internalTaskTimer = new Timer(TimerSupport.getTimerName(this), true);147 } else {148 internalTaskTimer = cleanupTaskTimer;149 }150 internalTaskTimer.schedule(cleanupTask, cleanupInterval, cleanupInterval);151 }152 }153 /** {@inheritDoc} */154 @Override protected void doDestroy() {155 if (cleanupTask != null) {156 cleanupTask.cancel();157 cleanupTask = null;158 if (cleanupTaskTimer == null) {159 internalTaskTimer.cancel();160 }161 internalTaskTimer = null;162 }163 super.doDestroy();164 }165 /** {@inheritDoc} */166 @Override @Nonnull public StorageCapabilities getCapabilities() {167 return this;168 }169 /** {@inheritDoc} */170 @Override public int getContextSize() {171 return contextSize;172 }...

Full Screen

Full Screen

cleanup

Using AI Code Generation

copy

Full Screen

1var1.hello("Ruby")2var1.hello("Python")3var1.hello("Perl")4var1.hello("PHP")5var1.hello("JavaScript")6var1.hello("Java")7var1.hello("C++")8var1.hello("C")9var1.hello("Go")10var1.hello("Swift")

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Unobtainium_ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful