I am using ConCahe for saving an image with its modified timestamps. It works fine, normally, and when I say normally then it works fine in logs as
def update_cache_and_save_thumbnail(camera_exid, timestamp, image) do
{last_save_date, t, img} = ConCache.dirty_get_or_store(:camera_thumbnail, camera_exid, fn() ->
{Calendar.DateTime.now!("UTC"), timestamp, image}
end)
Logger.info "This is dirty get or store"
IO.inspect ConCache.get(:camera_thumbnail, camera_exid)
Logger.info "==========================="
case Calendar.DateTime.diff(Calendar.DateTime.now!("UTC"), last_save_date) do
{:ok, seconds, _, :after} ->
thumbnail_save_seaweedfs(camera_exid, image, timestamp, last_save_date, seconds)
Logger.info "This is after thumnail save_seaweedfs"
IO.inspect ConCache.get(:camera_thumbnail, camera_exid)
Logger.info "==========================="
_ ->
Logger.info "This is will never run i think"
IO.inspect ConCache.get(:camera_thumbnail, camera_exid)
Logger.info "==========================="
ConCache.dirty_put(:camera_thumbnail, camera_exid, {last_save_date, timestamp, image})
end
end
when this function run and I am calling ConCache.get(:camera_thumbnail, "blessington_court")
in between and it’s giving me an updated value right away. such as
[info] This is dirty get or store
{#DateTime<2018-10-09 06:58:37.474918+00:00 UTC UTC>, 1539067937,
<<255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 2, 0, 0, 1, 0, 1, 0, 0, 255,
254, 0, 15, 10, 1, 91, 188, 80, 34, 11, 91, 188, 80, 34, 11, 1, 255, 254, 0,
15, 10, 0, 1, 219, 5, 80, ...>>}
[info] ===========================
{#DateTime<2018-10-09 06:58:37.474918+00:00 UTC UTC>, 1539067919,
<<255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 2, 0, 0, 1, 0, 1, 0, 0, 255,
254, 0, 15, 10, 1, 91, 188, 80, 21, 58, 91, 188, 80, 21, 58, 1, 255, 254, 0,
15, 10, 0, 1, 219, 5, 80, ...>>}
[info] This is after thumnail save_seaweedfs
[info] ===========================
[info] This is dirty get or store
{#DateTime<2018-10-09 06:58:37.474918+00:00 UTC UTC>, 1539067919,
<<255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 2, 0, 0, 1, 0, 1, 0, 0, 255,
254, 0, 15, 10, 1, 91, 188, 80, 21, 58, 91, 188, 80, 21, 58, 1, 255, 254, 0,
15, 10, 0, 1, 219, 5, 80, ...>>}
[info] ===========================
{#DateTime<2018-10-09 06:58:37.474918+00:00 UTC UTC>, 1539067934,
<<255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 2, 0, 0, 1, 0, 1, 0, 0, 255,
254, 0, 15, 10, 1, 91, 188, 80, 31, 78, 91, 188, 80, 31, 78, 1, 255, 254, 0,
15, 10, 0, 1, 219, 5, 80, ...>>}
[info] This is after thumnail save_seaweedfs
[info] ==========================
for once it gives duplicate but that’s because it’s been looking in cache. but whenever I do in the remote console as ConCache.get(:camera_thumbnail, “blessington_court”), It always gives the very old value. not the updated one.
{#DateTime<2018-10-09 06:25:56.691951+00:00 UTC UTC>, 1539065928,
<<255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 2, 0, 0, 1, 0, 1, 0, 0, 255,
254, 0, 15, 10, 1, 91, 188, 72, 63, 84, 91, 188, 72, 63, 84, 1, 255, 254, 0,
15, 10, 0, 1, 219, 5, 80, ...>>}
I have read the module docs for concache, But I didn’t find anything suitable which can pas the theory that it will give new value right away but old one when I can method by myself.? Can you guide me what is wrong happening in this? I tried this several times but it’s giving me an old value always.