/// <summary>
 /// construct the corresponding sorted set key for triggers based on its triggerState
 /// </summary>
 /// <param name="triggerState">RedisTriggerState</param>
 /// <returns>sorted set key</returns>
 public string TriggerStateSetKey(RedisTriggerState triggerState)
 {
     return this.AddPrefix(triggerState.GetDisplayName());
 }
        /// <summary>
        ///  Release triggers from the given current state to the new state if its locking scheduler has not registered as alive in the last triggerlocktimeout 
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="newState"></param>
        protected void ReleaseOrphanedTriggers(RedisTriggerState currentState, RedisTriggerState newState)
        {
            SortedSetEntry[] triggers = Db.SortedSetRangeByScoreWithScores(RedisJobStoreSchema.TriggerStateSetKey(currentState), 0, -1);

            foreach (var sortedSetEntry in triggers)
            {
                string lockedId =
                    Db.StringGet(
                        RedisJobStoreSchema.TriggerLockKey(
                            RedisJobStoreSchema.TriggerKey(sortedSetEntry.Element.ToString())));
                // Lock key has expired. We can safely alter the trigger's state.
                if (string.IsNullOrEmpty(lockedId))
                {
                    SetTriggerState(newState, sortedSetEntry.Score, sortedSetEntry.Element);
                }
            }
        }
 /// <summary>
 /// Set a trigger state by adding the trigger to the relevant sorted set, using its next fire time as the score.
 /// </summary>
 /// <param name="state">RedisTriggerState</param>
 /// <param name="score">time in milli seconds from epoch time</param>
 /// <param name="triggerHashKey">TriggerHashKey</param>
 /// <returns>succeeds or not</returns>
 protected bool SetTriggerState(RedisTriggerState state, double score, string triggerHashKey)
 {
     this.UnsetTriggerState(triggerHashKey);
     return Db.SortedSetAdd(RedisJobStoreSchema.TriggerStateSetKey(state), triggerHashKey, score);
 }
 /// <summary>
 /// construct the corresponding sorted set key for triggers based on its triggerState
 /// </summary>
 /// <param name="triggerState">RedisTriggerState</param>
 /// <returns>sorted set key</returns>
 public string TriggerStateSetKey(RedisTriggerState triggerState)
 {
     return(this.AddPrefix(triggerState.GetDisplayName()));
 }