1

I have the following Job class representing runs of a job. I have a list of start and end times in Job class because the same Job can be rerun.

public class Job {

      private final List<Timestamp> jobStartTimes = new SortedList<>();
      private final List<Timestamp> jobEndTimes = new SortedList<>();
      private String jobName;
      private String jobKey;
      private String host;
      ....
      ....
}

I have this Map for querying jobs given jobkey.

public class JobMap {

         /**
         * Here value of 'String' key is jobKey
         */
         private final Map<String, Job> jobCache;
}

I have also created the following hierarchy of hashmaps for storing (starttime, jobKey) and (endtime, jobkey) entries in Map so that I can retrieve job records faster. This is needed because my queries are timestamp based, for ex: return all jobs that ran between x and y timestamp.

public class YearCache<T> {

        /**
         * Here value of 'Integer' key is month number (0, 11)
         */
        private final Map<Integer, MonthCache> monthCache;
}

public class MonthCache {

        /**
         * Here value of 'Integer' key is week number in a month(0, 4)
         */
        private final Map<Integer, WeekCache> weekCache;
}

public class WeekCache {

        /**
         * Here value of 'Integer' key is day number in a week (0, 6)
         */
        private final Map<Integer, DayCache> dayCache;
}

private class DayCache
{
        /**
         * Here value of 'Integer' key is hour value in a day (0, 23)
         * T is of type String representing jobKey
         */
         private final NavigableMap<Integer, NavigableMap<Timestamp, Set<T>>> hourCache;
}

I want to get rid of this Java hashmaps and move to Redis Cache. How can I model/architect this hierarchy in Redis Cache?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.