Skip to content

Instantly share code, notes, and snippets.

@alekseyl
Last active May 18, 2018 08:25
Show Gist options
  • Save alekseyl/6b8f8fbc25f1e04c9ec6fb5b1e6aa57d to your computer and use it in GitHub Desktop.
Save alekseyl/6b8f8fbc25f1e04c9ec6fb5b1e6aa57d to your computer and use it in GitHub Desktop.
MeRedis confiugure examples
Redis.include( MeRedis )
# zip key crumbs user, card, card_preview, zips integer crumbs to base62,
# for keys starting with card_preview prefix compress values with Zlib
# for keys starting with user or card compress values with ActiveRecordJSONCompressor
Redis.configure(
hash_max_ziplist_entries: 256,
zip_crumbs: %i[user card card_preview], # -> { user: :u, card: :c, card_preview: :c0 }
integers_to_base62: true,
compress_namespaces: {
:card_preview => MeRedis::ZipValues::ZlibCompressor,
%i[user card] => ActiveRecordJSONCompressor
}
)
# key zipping directly like this:
Redis.configure(
hash_max_ziplist_entries: 256,
zip_crumbs: { user: :u, card: :c, card_preview: :cp],
integers_to_base62: true,
)
Redis.include( MeRedis ) # or Redis.prepend( MeRedis::ZipValues )
# don't zip keys just values,
# for keys started with :user, :card, :card_preview
# compress all values with default compressor
# default compressor is ZlibCompressor if you prepend ZipValues module or include whole MeRedis module,
# otherwise it is EmptyCompressor which doesn't compress anything
Redis.configure(
hash_max_ziplist_entries: 256,
compress_namespaces: %i[user card card_preview]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment