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

Allow storing raw strings, not the whole Nebulex.Object.t() #15

Closed
cabol opened this issue Nov 8, 2019 · 1 comment
Closed

Allow storing raw strings, not the whole Nebulex.Object.t() #15

cabol opened this issue Nov 8, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@cabol
Copy link
Owner

cabol commented Nov 8, 2019

Currently, bay default, all values except the counters are stored as Nebulex.Object.t() (before to put the data on Redis, the object is encoded as binary). The idea is to allow storing raw strings, not within the object, and improve the memory consumption for string data types.

@cabol cabol added the enhancement New feature or request label Nov 8, 2019
@cabol
Copy link
Owner Author

cabol commented Nov 8, 2019

Proposed solution

Supporting for "data types" starting with strings. Two additional options:

  • :dt - This option is for write-like operations like set, add, replace, set_many, etc., and allows to change how to store the data in Redis, for example, by default is the Nebulex object, but if we pass :string, there shouldn't be any encoding if the given value is a valid string.

  • default_data_type - In order to avoid always passing the previous option for all write-like commands, we can change the default data type encoding globally.

By default, for both options the value is :object (the current behavior).

Usage Example

Cache.set("foo", "bar", dt: :string)

# the string dt is applied to all given values
Cache.set_many(%{"a" => "a", "b" => "b"}, dt: :string)

Globally:

config :my_app, MyApp.Cache,
  default_data_type: :string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant