Module: MeRedis::ZipValues
- Defined in:
- lib/me_redis/zip_values.rb
Overview
todo warn in development that gzipped size iz bigger than strict use prepend for classes or extend on instances
Defined Under Namespace
Modules: EmptyCompressor, FutureUnzip, PrependMethods, ZlibCompressor
Class Method Summary
collapse
Instance Method Summary
collapse
-
#get(key) ⇒ Object
-
#getset(key, value) ⇒ Object
-
#hget(key, h_key) ⇒ Object
-
#hmget(key, *args) ⇒ Object
-
#hmset(key, *args) ⇒ Object
-
#hset(key, h_key, value) ⇒ Object
-
#hsetnx(key, h_key, value) ⇒ Object
-
#mget(*args) ⇒ Object
-
#mset(*args) ⇒ Object
-
#set(key, value) ⇒ Object
-
#unzip_value(value, key) ⇒ Object
-
#zip?(key) ⇒ Boolean
-
#zip_value(value, key) ⇒ Object
Class Method Details
.prepended(base) ⇒ Object
Instance Method Details
#get(key) ⇒ Object
111
|
# File 'lib/me_redis/zip_values.rb', line 111
def get( key ); unzip_value( super( key ), key) end
|
#getset(key, value) ⇒ Object
117
|
# File 'lib/me_redis/zip_values.rb', line 117
def getset( key, value ); unzip_value( super( key, zip_value(value, key) ), key ) end
|
#hget(key, h_key) ⇒ Object
119
|
# File 'lib/me_redis/zip_values.rb', line 119
def hget( key, h_key ); unzip_value( super( key, h_key ), key ) end
|
#hmget(key, *args) ⇒ Object
125
|
# File 'lib/me_redis/zip_values.rb', line 125
def hmget( key, *args ); unzip_arr_or_future( super(key, *args), key ) end
|
#hmset(key, *args) ⇒ Object
123
|
# File 'lib/me_redis/zip_values.rb', line 123
def hmset( key, *args ); super( key, map_hmsets_arr(key, *args) ) end
|
#hset(key, h_key, value) ⇒ Object
120
|
# File 'lib/me_redis/zip_values.rb', line 120
def hset( key, h_key, value ); super( key, h_key, zip_value(value, key) ) end
|
#hsetnx(key, h_key, value) ⇒ Object
121
|
# File 'lib/me_redis/zip_values.rb', line 121
def hsetnx( key, h_key, value ); super( key, h_key, zip_value(value, key) ) end
|
#mget(*args) ⇒ Object
114
|
# File 'lib/me_redis/zip_values.rb', line 114
def mget(*args); unzip_arr_or_future(super(*args), args ) end
|
#mset(*args) ⇒ Object
115
|
# File 'lib/me_redis/zip_values.rb', line 115
def mset(*args); super( *map_msets_arr(args) ) end
|
#set(key, value) ⇒ Object
112
|
# File 'lib/me_redis/zip_values.rb', line 112
def set( key, value ); super( key, zip_value(value, key) ) end
|
#unzip_value(value, key) ⇒ Object
102
103
104
105
106
|
# File 'lib/me_redis/zip_values.rb', line 102
def unzip_value(value, key)
return value if value.is_a?( FutureUnzip )
value.is_a?(String) && zip?(key) ? self.class.get_compressor_for_key(key).decompress( value ) : value
end
|
#zip?(key) ⇒ Boolean
108
|
# File 'lib/me_redis/zip_values.rb', line 108
def zip?(key); self.class.zip?(key) end
|
#zip_value(value, key) ⇒ Object
98
99
100
|
# File 'lib/me_redis/zip_values.rb', line 98
def zip_value(value, key )
zip?(key) ? self.class.get_compressor_for_key(key).compress( value ) : value
end
|