Module: Fuzzzy::Redis
- Included in:
- MethodBase
- Defined in:
- lib/fuzzzy/redis.rb
Constant Summary collapse
- INDEX_KEY =
Ruby implementation is: def index_key key, key2=nil
key = "#{key}:#key2" if key2 "#{shared_key}:#{index_key}:#{key}"end
"VALUE \n_index_key(int argc, VALUE *argv, VALUE self) \n{\n VALUE type = rb_funcall(self, rb_intern(\"index_type\"), 0);\n VALUE shared_key = rb_funcall(self, rb_intern(\"shared_key\"), 0);\n char sep[2] = \":\";\n VALUE key, key2, result;\n char * buf;\n unsigned long long length;\n\n if(rb_scan_args(argc, argv, \"11\", &key, &key2) == 2) {\n key = rb_str_dup(key);\n rb_str_cat(key, sep, 1);\n rb_str_concat(key, rb_funcall(key2, rb_intern(\"to_s\"), 0));\n }\n\n length = RSTRING_LEN(shared_key) + RSTRING_LEN(type) + RSTRING_LEN(key) + 4;\n buf = malloc(length);\n snprintf(buf, length, \"%s:%s:%s\", RSTRING_PTR(shared_key), RSTRING_PTR(type), RSTRING_PTR(key));\n result = rb_str_new2(buf);\n free(buf);\n\n return result;\n}\n"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.counter_key ⇒ Object
57 58 59 |
# File 'lib/fuzzzy/redis.rb', line 57 def self.counter_key "fuzzzy:indexes:info" end |
Instance Method Details
#counter_key ⇒ Object
53 54 55 |
# File 'lib/fuzzzy/redis.rb', line 53 def counter_key "fuzzzy:indexes:info" end |
#dictionary_key(id) ⇒ Object
49 50 51 |
# File 'lib/fuzzzy/redis.rb', line 49 def dictionary_key id "#{shared_key}:dictionary:#{id}" end |
#redis ⇒ Object
41 42 43 |
# File 'lib/fuzzzy/redis.rb', line 41 def redis Fuzzzy.redis end |
#shared_key ⇒ Object
45 46 47 |
# File 'lib/fuzzzy/redis.rb', line 45 def shared_key context[:shared_key] ||= "fuzzzy:#{index_name}" end |