Skip to content

Commit

Permalink
Project updates
Browse files Browse the repository at this point in the history
  • Loading branch information
raphasampaio committed Aug 21, 2024
1 parent 74ccc77 commit b1a9767
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
11 changes: 5 additions & 6 deletions src/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ function finalize!(cache::Cache)
return nothing
end

function format_value(value::Any)
function format_value(value::Any)::String
return "$value"
end

function format_value(value::DateTime)
function format_value(value::DateTime)::String
return Dates.format(value, "yyyymmddHHMMSS")
end

function build_filename(kwargs...)
function build_key(kwargs...)
dict = Dict(kwargs)
sorted = sort(collect(dict), by = x -> x[1])

Expand All @@ -51,9 +51,8 @@ function build_filename(kwargs...)
return join(vector, "-") * ".bin"
end

function update!(inputs::AbstractInputs, cache::Cache; kwargs...)
filename = build_filename(kwargs...)
path = joinpath(cache.path, filename)
function update!(inputs::AbstractInputs, cache::Cache, key::AbstractString; kwargs...)
path = joinpath(cache.path, "$key.bin")

if isfile(path)
if cache.verbose
Expand Down
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ function test_all()

for _ in 1:ITERATIONS
for date_time in DATE_TIMES
@timeit "cached - update!" update!(inputs, cache, date_time = date_time)
key = Dates.format(date_time, "yyyymmdd")
@timeit "cached - update!" update!(inputs, cache, key; date_time = date_time)

for i in 1:HYDRO_PLANT_SIZE
time_series_float = build_float(date_time)
Expand Down

0 comments on commit b1a9767

Please sign in to comment.