/// <summary> /// Remove (delete) the <see cref="T:Quartz.IJob"/> with the given /// key, and any <see cref="T:Quartz.ITrigger"/> s that reference /// it. /// </summary> /// <remarks> /// If removal of the <see cref="T:Quartz.IJob"/> results in an empty group, the /// group should be removed from the <see cref="T:Quartz.Spi.IJobStore"/>'s list of /// known group names. /// </remarks> /// <returns> /// <see langword="true"/> if a <see cref="T:Quartz.IJob"/> with the given name and /// group was found and removed from the store. /// </returns> public override bool RemoveJob(JobKey jobKey) { var jobHashKey = RedisJobStoreSchema.JobHashKey(jobKey); var jobDataMapHashKey = RedisJobStoreSchema.JobDataMapHashKey(jobKey); var jobGroupSetKey = RedisJobStoreSchema.JobGroupSetKey(jobKey.Group); var jobTriggerSetKey = RedisJobStoreSchema.JobTriggersSetKey(jobKey); var delJobHashKeyResult = Db.KeyDelete(jobHashKey); Db.KeyDelete(jobDataMapHashKey); Db.SetRemove(RedisJobStoreSchema.JobsSetKey(), jobHashKey); Db.SetRemove(jobGroupSetKey, jobHashKey); var jobTriggerSetResult = Db.SetMembers(jobTriggerSetKey); Db.KeyDelete(jobTriggerSetKey); var jobGroupSetLengthResult = Db.SetLength(jobGroupSetKey); if (jobGroupSetLengthResult == 0) { Db.SetRemoveAsync(RedisJobStoreSchema.JobGroupsSetKey(), jobGroupSetKey); } // remove all triggers associated with this job foreach (var triggerHashKey in jobTriggerSetResult) { var triggerkey = RedisJobStoreSchema.TriggerKey(triggerHashKey); var triggerGroupKey = RedisJobStoreSchema.TriggerGroupSetKey(triggerkey.Group); this.UnsetTriggerState(triggerHashKey); Db.SetRemove(RedisJobStoreSchema.TriggersSetKey(), triggerHashKey); Db.SetRemove(RedisJobStoreSchema.TriggerGroupsSetKey(), triggerGroupKey); Db.SetRemove(RedisJobStoreSchema.TriggerGroupSetKey(triggerkey.Group), triggerHashKey); Db.KeyDelete(triggerHashKey.ToString()); } return(delJobHashKeyResult); }
/// <summary> /// Store the given <see cref="T:Quartz.IJobDetail"/>. /// </summary> /// <param name="jobDetail">The <see cref="T:Quartz.IJobDetail"/> to be stored.</param><param name="replaceExisting">If <see langword="true"/>, any <see cref="T:Quartz.IJob"/> existing in the /// <see cref="T:Quartz.Spi.IJobStore"/> with the same name and group should be /// over-written. /// </param> public override void StoreJob(IJobDetail jobDetail, bool replaceExisting) { var jobHashKey = RedisJobStoreSchema.JobHashKey(jobDetail.Key); var jobDataMapHashKey = RedisJobStoreSchema.JobDataMapHashKey(jobDetail.Key); var jobGroupSetKey = RedisJobStoreSchema.JobGroupSetKey(jobDetail.Key.Group); if (Db.KeyExists(jobHashKey) && !replaceExisting) { throw new ObjectAlreadyExistsException(jobDetail); } Db.HashSet(jobHashKey, ConvertToHashEntries(jobDetail)); Db.HashSet(jobDataMapHashKey, ConvertToHashEntries(jobDetail.JobDataMap)); Db.SetAdd(RedisJobStoreSchema.JobsSetKey(), jobHashKey); Db.SetAdd(RedisJobStoreSchema.JobGroupsSetKey(), jobGroupSetKey); Db.SetAdd(jobGroupSetKey, jobHashKey); }