Repository: whitfin/cachex (elixir)
Issue: Remove set and set_many from the public API
These functions were deprecated in 3.0. They can finally be removed!
Pull request description: Remove set and set_many from the main API
This fixes #337.

These functions were left behind in 3.0 as backwards compatibility. It's time to finally remove them now that we're shipping a new major version!

Patch:
diff --git a/lib/cachex.ex b/lib/cachex.ex
index c5df593..5c8e1cf 100644
--- a/lib/cachex.ex
+++ b/lib/cachex.ex
@@ -89,8 +89,6 @@ defmodule Cachex do
     put_many: [2, 3],
     refresh: [2, 3],
     reset: [1, 2],
-    set: [3, 4],
-    set_many: [2, 3],
     size: [1, 2],
     stats: [1, 2],
     stream: [1, 2, 3],
@@ -1147,24 +1145,6 @@ defmodule Cachex do
   def reset(cache, options \\ []) when is_list(options),
     do: Router.call(cache, {:reset, [options]})
 
-  @doc """
-  Deprecated implementation delegate of `put/4`.
-  """
-  if Version.match?(System.version(), ">= 1.6.0"),
-    do: @deprecated("Please migrate to using put/4 instead.")
-
-  def set(cache, key, value, options \\ []),
-    do: put(cache, key, value, options)
-
-  @doc """
-  Deprecated implementation delegate of `put_many/3`.
-  """
-  if Version.match?(System.version(), ">= 1.6.0"),
-    do: @deprecated("Please migrate to using put_many/3 instead.")
-
-  def set_many(cache, pairs, options \\ []),
-    do: put_many(cache, pairs, options)
-
   @doc """
   Retrieves the total size of a cache.
 


Test patch:
diff --git a/test/cachex/actions/set_many_test.exs b/test/cachex/actions/set_many_test.exs
deleted file mode 100644
index de62aa6..0000000
--- a/test/cachex/actions/set_many_test.exs
+++ /dev/null
@@ -1,73 +0,0 @@
-defmodule Cachex.Actions.SetManyTest do
-  use CachexCase
-
-  # This test just covers the case of forwarding calls
-  # to set_many() through to put_many() in order to
-  # validate the backwards compatibility calls.
-  test "forwarding calls to put_many(2/3)" do
-    # create a test cache
-    cache = Helper.create_cache()
-
-    # set values in the cache
-    result1 = Cachex.set_many(cache, [{1, 1}, {2, 2}])
-    result2 = Cachex.set_many(cache, [{3, 3}, {4, 4}], ttl: 5000)
-
-    # verify the results of the writes
-    assert(result1 == {:ok, true})
-    assert(result2 == {:ok, true})
-
-    # retrieve the written value
-    result2 = Cachex.get(cache, 1)
-    result3 = Cachex.get(cache, 2)
-    result4 = Cachex.get(cache, 3)
-    result5 = Cachex.get(cache, 4)
-
-    # check that it was written
-    assert(result2 == {:ok, 1})
-    assert(result3 == {:ok, 2})
-    assert(result4 == {:ok, 3})
-    assert(result5 == {:ok, 4})
-
-    # check the ttl on the last calls
-    result6 = Cachex.ttl!(cache, 3)
-    result7 = Cachex.ttl!(cache, 4)
-
-    # the second should have a TTL around 5s
-    assert_in_delta(result6, 5000, 10)
-    assert_in_delta(result7, 5000, 10)
-  end
-
-  # This test verifies that this action is correctly distributed across
-  # a cache cluster, instead of just the local node. We're not concerned
-  # about the actual behaviour here, only the routing of the action.
-  @tag distributed: true
-  test "adding new entries to a cache cluster" do
-    # create a new cache cluster for cleaning
-    {cache, _nodes} = Helper.create_cache_cluster(2)
-
-    # we know that 2 & 3 hash to the same slots
-    {:ok, true} = Cachex.set_many(cache, [{2, 2}, {3, 3}])
-
-    # try to retrieve both of the set keys
-    get1 = Cachex.get(cache, 2)
-    get2 = Cachex.get(cache, 3)
-
-    # both should come back
-    assert(get1 == {:ok, 2})
-    assert(get2 == {:ok, 3})
-  end
-
-  # This test verifies that all keys in a set_many/3 must hash to the
-  # same slot in a cluster, otherwise a cross_slot error will occur.
-  @tag distributed: true
-  test "multiple slots will return a :cross_slot error" do
-    # create a new cache cluster for cleaning
-    {cache, _nodes} = Helper.create_cache_cluster(2)
-
-    # we know that 1 & 3 don't hash to the same slots
-    set_many = Cachex.set_many(cache, [{1, 1}, {3, 3}])
-
-    # so there should be an error
-    assert(set_many == {:error, :cross_slot})
-  end
-end
diff --git a/test/cachex/actions/set_test.exs b/test/cachex/actions/set_test.exs
deleted file mode 100644
index c32284f..0000000
--- a/test/cachex/actions/set_test.exs
+++ /dev/null
@@ -1,54 +0,0 @@
-defmodule Cachex.Actions.SetTest do
-  use CachexCase
-
-  # This test just covers the case of forwarding calls
-  # to set() through to put() in order to validate the
-  # backwards compatibility of the deprecated calls.
-  test "forwarding calls to put(3/4)" do
-    # create a test cache
-    cache = Helper.create_cache()
-
-    # set values in the cache
-    result1 = Cachex.set(cache, 1, 1)
-    result2 = Cachex.set(cache, 2, 2, ttl: 5000)
-
-    # verify the results of the writes
-    assert(result1 == {:ok, true})
-    assert(result2 == {:ok, true})
-
-    # retrieve the written value
-    result2 = Cachex.get(cache, 1)
-    result3 = Cachex.get(cache, 2)
-
-    # check that it was written
-    assert(result2 == {:ok, 1})
-    assert(result3 == {:ok, 2})
-
-    # check the ttl on the second call
-    result4 = Cachex.ttl!(cache, 2)
-
-    # the second should have a TTL around 5s
-    assert_in_delta(result4, 5000, 10)
-  end
-
-  # This test verifies that this action is correctly distributed across
-  # a cache cluster, instead of just the local node. We're not concerned
-  # about the actual behaviour here, only the routing of the action.
-  @tag distributed: true
-  test "forwarding calls to put(3/4) in a cache cluster" do
-    # create a new cache cluster for cleaning
-    {cache, _nodes} = Helper.create_cache_cluster(2)
-
-    # we know that 1 & 2 hash to different nodes
-    {:ok, true} = Cachex.set(cache, 1, 1)
-    {:ok, true} = Cachex.set(cache, 2, 2)
-
-    # check the results of the calls across nodes
-    size1 = Cachex.size(cache, local: true)
-    size2 = Cachex.size(cache, local: false)
-
-    # one local, two total
-    assert(size1 == {:ok, 1})
-    assert(size2 == {:ok, 2})
-  end
-end
diff --git a/test/cachex_test.exs b/test/cachex_test.exs
index 19bd024..79d5d0d 100644
--- a/test/cachex_test.exs
+++ b/test/cachex_test.exs
@@ -177,7 +177,7 @@ defmodule CachexTest do
     assert(is_even(length(definitions)))
 
     # verify the size to cause errors on addition/removal
-    assert(length(definitions) == 156)
+    assert(length(definitions) == 148)
 
     # validate all definitions
     for {name, arity} <- definitions do