Closed tominkozhimala closed 6 years ago
My first guess is that the child_spec
function is being called on ConCache.Owner
and failing, since it doesn't exist yet in 0.12.1
.
I assume this error wouldn't occur on module-based supervisors once the child_spec
changes from earlier this month are released. Any word on when the merged changes will be released as a hex package?
My first guess is that the child_spec function is being called on ConCache.Owner and failing, since it doesn't exist yet in 0.12.1.
I assume this error wouldn't occur on module-based supervisors once the child_spec changes from earlier this month are released. Any word on when the merged changes will be released as a hex package?
Yes, you're right that it doesn't work because the current master has not yet been released. The main reason is because there have been some breaking changes in #42 and #44 which I want to review, and create the changelog. I didn't manage to find the time for this because I was busy with other things (most notably the work on the 2nd edition of Elixir in Action), but I'll make it a priority now, and see about releasing the new version as soon as possible.
In the meantime, you have two options.
The first option is to depend on the GitHub version instead of hex. This will work, but the annoying thing is that the official docs at hexdoc.pm are incorrect when it comes to ttl configuration. You can refer to the latest README for explanation.
Another approach is to use the latest published version, and create your own child_spec
. Here's the spec which should work:
Supervisor.start_link(
[
%{
id: :my_cache,
type: :supervisor,
start: {ConCache, :start_link, [[], [name: :my_cache]]}
}
],
strategy: :one_for_one,
name: Test.Supervisor
)
The reason why you need this particular shape of the :start
key is because start_link
in 0.12.1 takes two arguments.
I agree that this is all unfortunate and confusing, so I'll make it a priority to release the new version as soon as possible.
The new version (0.13.0) is now published to hex.
Thanks for the quick turnaround, @sasa1977
Seems to be working as expected now. Just had to add ttl_check_interval: false
as an option.
Version information:
Alpine Linux 3.7
(using Docker)Elixir 1.5.3 (compiled with OTP 20)
ConCache 0.12.1
Currently attempting to integrate ConCache into my existing project, which uses a module-based supervisor to manage child processes:
Then, I attempt to call my cache from one of the other children processes in the above Supervision tree. However, my application is crashing with the following error:
So, I replaced my
Supervisor.child_spec/2
function as follows:This causes my application to crash with the following error:
Is there an existing workaround to get this functioning?