parent
							
								
									dea0ff8819
								
							
						
					
					
						commit
						fc20fa7f5f
					
				| @ -0,0 +1,22 @@ | ||||
| class HotSearchKeyword | ||||
|   class << self | ||||
|     def add(keyword) | ||||
|       return if keyword.blank? | ||||
|       Rails.cache.data.zincrby(redis_key, 1, keyword) | ||||
|     end | ||||
| 
 | ||||
|     def hot(limit = 5) | ||||
|       Rails.cache.data.zrevrange(redis_key, 0, limit - 1) | ||||
|     end | ||||
| 
 | ||||
|     def available? | ||||
|       Rails.cache.is_a?(ActiveSupport::Cache::RedisStore) | ||||
|     end | ||||
| 
 | ||||
|     private | ||||
| 
 | ||||
|     def redis_key | ||||
|       'educoder:es:hot_keyword' | ||||
|     end | ||||
|   end | ||||
| end | ||||
					Loading…
					
					
				
		Reference in new issue