Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable codec to encode/decode Redis keys and values #45

Closed
cabol opened this issue Mar 6, 2023 · 0 comments
Closed

Configurable codec to encode/decode Redis keys and values #45

cabol opened this issue Mar 6, 2023 · 0 comments
Labels

Comments

@cabol
Copy link
Owner

cabol commented Mar 6, 2023

Currently, the adapter encodes and decodes Redis keys and values automatically underneath, it encodes any Elixir term to a binary and decodes binaries into Elixir terms. The idea is to allow the user to optionally provide a custom codec with the option :codec. The value must be a module implementing the NebulexRedisAdapter.Codec behaviour.

This is how the behaviour may look like:

defmodule NebulexRedisAdapter.Codec do
  @moduledoc """
  Codec interface.
  """

  @doc """
  Encodes `key` with the given `opts`.
  """
  @callback encode_key(key :: term, opts :: [term]) :: iodata

  @doc """
  Encodes `value` with the given `opts`.
  """
  @callback encode_value(value :: term, opts :: [term]) :: iodata

  @doc """
  Decodes `key` with the given `opts`.
  """
  @callback decode_key(key :: binary, opts :: [term]) :: term

  @doc """
  Decodes `value` with the given `opts`.
  """
  @callback decode_value(value :: binary, opts :: [term]) :: term
end
@cabol cabol added the feature label Mar 6, 2023
cabol added a commit that referenced this issue Mar 12, 2023
[#45] Configurable codec to encode/decode Redis keys and values
Improve Redis 7 support for Redis Cluster
Rename `StringProto` to `StringCodec`
@cabol cabol closed this as completed Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant