Rename the key for the cache. #689

This commit is contained in:
Korina Cordero 2022-06-30 04:18:35 +00:00
parent 7b1b56c899
commit 33ae3b624d
2 changed files with 9 additions and 9 deletions

View file

@ -247,7 +247,7 @@ services:
App\Service\JobOrderJsonCache: App\Service\JobOrderJsonCache:
arguments: arguments:
$redis_prov: "@App\\Service\\RedisClientProvider" $redis_prov: "@App\\Service\\RedisClientProvider"
$jo_json_info_key: "%env(JO_JSON_INFO_KEY)%" $jo_json_cache_key: "%env(JO_JSON_CACHE_KEY)%"
# inventory manager # inventory manager
App\Service\InventoryManager: App\Service\InventoryManager:

View file

@ -7,19 +7,19 @@ use App\Service\RedisClientProvider;
class JobOrderJsonCache class JobOrderJsonCache
{ {
protected $redis; protected $redis;
protected $jo_json_info_key; protected $jo_json_cache_key;
public function __construct(RedisClientProvider $redis_prov, $jo_json_info_key) public function __construct(RedisClientProvider $redis_prov, $jo_json_cache_key)
{ {
$this->redis = $redis_prov->getRedisClient(); $this->redis = $redis_prov->getRedisClient();
$this->jo_json_info_key = $jo_json_info_key; $this->jo_json_cache_key = $jo_json_cache_key;
} }
public function addJOJsonInfo($jo_id, $jo_data) public function addJOJsonInfo($jo_id, $jo_data)
{ {
$key = $jo_id; $key = $jo_id;
$this->redis->hset($this->jo_json_info_key, $key, $jo_data); $this->redis->hset($this->jo_json_cache_key, $key, $jo_data);
} }
public function findJOJsonInfo($jo_id) public function findJOJsonInfo($jo_id)
@ -29,11 +29,11 @@ class JobOrderJsonCache
$key = $jo_id; $key = $jo_id;
// check if JO id is in redis hash // check if JO id is in redis hash
$is_exist = $this->redis->hexists($this->jo_json_info_key, $key); $is_exist = $this->redis->hexists($this->jo_json_cache_key, $key);
if ($is_exist) if ($is_exist)
{ {
// get the data // get the data
$jo_data = $this->redis->hget($this->jo_json_info_key, $key); $jo_data = $this->redis->hget($this->jo_json_cache_key, $key);
} }
return $jo_data; return $jo_data;
@ -44,10 +44,10 @@ class JobOrderJsonCache
$key = $jo_id; $key = $jo_id;
// check if JO id is in redis hash // check if JO id is in redis hash
$is_exist = $this->redis->hexists($this->jo_json_info_key, $key); $is_exist = $this->redis->hexists($this->jo_json_cache_key, $key);
if ($is_exist) if ($is_exist)
{ {
$this->redis->hdel($this->jo_json_info_key, $key); $this->redis->hdel($this->jo_json_cache_key, $key);
} }
} }
} }