def store_keyword_cache(job_keyword_dto: JobKeywordDTO): job_id = job_keyword_dto.job_id if not enable_cache: return if keyword_cache_exist(job_id): return redis_template.db(2).set(job_id, job_keyword_dto.to_json())
def set_standard_word_cache(other_word: str, standard_word: str): if not enable_cache: return redis_template.db(3).set(other_word, standard_word) logger.info( f"stored the standard word: {standard_word} of {other_word} in redis as cache" )
def get_matrix_cache() -> Optional[np.ndarray]: if not enable_cache: return cache = redis_template.db(0).get(MATRIX_KEY) if cache: logger.info("found matrix cache in redis") return np.asarray(json.loads(cache), dtype=np.int16)
def get_keyword_df_cache() -> Optional[pd.DataFrame]: if not enable_cache: return cache = redis_template.db(0).get(KEYWORD_DF_KEY) if cache: logger.info("found the keyword_df cache in redis") return pd.read_msgpack(cache)
def get_standard_word_cache(other_word: str) -> str: cache = redis_template.db(3).get(other_word) if cache: return cache.decode("utf-8") else: standard_word = select_standard_word(other_word) return standard_word
def standard_word_cache_exist(other_word: str): cache = redis_template.db(3).get(other_word) if cache: return True return False
def store_matrix_cache(matrix: np.ndarray): if not enable_cache: return redis_template.db(0).set(MATRIX_KEY, json.dumps(matrix.tolist())) logger.info("stored the matrix in redis as cache")
def store_keyword_df_cache(df: pd.DataFrame): if not enable_cache: return redis_template.db(0).set(KEYWORD_DF_KEY, df.to_msgpack(compress="zlib")) logger.info("stored the keyword_df in redis as cache")
def get_standard_category_cache(standard_word: str) -> Optional[str]: cache = redis_template.db(4).get(standard_word) if cache: return cache.decode("utf-8") else: return
def store_standard_category_cache(standard_word: str, standard_category: str): redis_template.db(4).set(standard_word, standard_category)
def store_standard_word_cache(other_word: str, standard_word: str): redis_template.db(3).set(other_word, standard_word)
def keyword_cache_exist(job_id: str): cache = redis_template.db(2).get(job_id) if cache: return True return False
def get_keyword_cache(job_id: str): if not enable_cache: return cache = redis_template.db(2).get(job_id) return to_obj(JobKeywordDTO(), cache) if cache else None