Class: Looksist::RedisService
- Inherits:
-
Object
- Object
- Looksist::RedisService
- Defined in:
- lib/looksist/redis_service.rb
Instance Attribute Summary collapse
-
#buffer_size ⇒ Object
Returns the value of attribute buffer_size.
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#client ⇒ Object
Returns the value of attribute client.
Class Method Summary collapse
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/looksist/redis_service.rb', line 18 def method_missing(name, *args, &block) if name.to_s.ends_with?('_for') entity = name.to_s.gsub('_for', '') first_arg = args.first first_arg.is_a?(Array) ? find_all(entity, first_arg) : find(entity, first_arg) else super(name, args) end end |
Instance Attribute Details
#buffer_size ⇒ Object
Returns the value of attribute buffer_size.
4 5 6 |
# File 'lib/looksist/redis_service.rb', line 4 def buffer_size @buffer_size end |
#cache ⇒ Object
Returns the value of attribute cache.
4 5 6 |
# File 'lib/looksist/redis_service.rb', line 4 def cache @cache end |
#client ⇒ Object
Returns the value of attribute client.
4 5 6 |
# File 'lib/looksist/redis_service.rb', line 4 def client @client end |
Class Method Details
.instance {|@this| ... } ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/looksist/redis_service.rb', line 9 def instance @this ||= new @this.buffer_size = 50000 yield @this if block_given? @this.cache = SafeLruCache.new(@this.buffer_size) @this end |
Instance Method Details
#flush_cache! ⇒ Object
28 29 30 |
# File 'lib/looksist/redis_service.rb', line 28 def flush_cache! @cache.clear end |