#! /usr/bin/julia
#
# mcached_update.jl
#
# Dec/30/2021
# --------------------------------------------------------------------
using Memcache
using JSON
# --------------------------------------------------------------------
println(stderr,"*** 開始 ***")
key_in = ARGS[1]
population_in = ARGS[2]
println(key_in,'\t',population_in)
#
mc = MemcacheClient("localhost", 11211)
#
try
str_json = get(mc,key_in)
println(str_json)
unit_aa = JSON.parse(str_json)
unit_aa["population"] = population_in
today = Libc.strftime("%F", time())
unit_aa["date_mod"] = today
str_json_new = JSON.json(unit_aa)
println(str_json_new)
set(mc,key_in,str_json_new)
catch
end
#
println(stderr,"*** 終了 ***")
# --------------------------------------------------------------------