statistics.ex (430B)
1 defmodule Utilities.Statistics do 2 use GenServer 3 4 def init(opts) do 5 :ets.new(:statistics, [:set, :public, :named_table]) 6 {:ok, opts} 7 end 8 9 def insert(generation, statistics) do 10 :ets.insert(:statistics, {generation, statistics}) 11 end 12 13 def lookup(generation) do 14 hd(:ets.lookup(:statistics, generation)) 15 end 16 17 def start_link(opts) do 18 GenServer.start_link(__MODULE__, opts, name: __MODULE__) 19 end 20 end