Class: EVSS::Dependents::RetrievedInfo
- Inherits:
-
Common::RedisStore
- Object
- Common::RedisStore
- EVSS::Dependents::RetrievedInfo
- Includes:
- Common::CacheAside
- Defined in:
- lib/evss/dependents/retrieved_info.rb
Overview
Model for caching a user’s retrieved info.
Constant Summary
Constants inherited from Common::RedisStore
Common::RedisStore::REQ_CLASS_INSTANCE_VARS
Instance Attribute Summary collapse
-
#user ⇒ User
User object.
Class Method Summary collapse
-
.for_user(user) ⇒ RetrievedInfo
Fetches retreived info for a user.
Instance Method Summary collapse
-
#body ⇒ Hash
Creates a cached instance of a user’s retrieved info.
-
#delete ⇒ Object
Deletes retrieved info cache.
Methods included from Common::CacheAside
#cache, #cached?, #do_cached_with, #set_attributes
Methods inherited from Common::RedisStore
create, delete, #destroy, #destroyed?, exists?, #expire, find, find_or_build, #initialize, #initialize_dup, keys, #persisted?, pop, redis_key, redis_store, redis_ttl, #save, #save!, #ttl, #update, #update!
Constructor Details
This class inherits a constructor from Common::RedisStore
Instance Attribute Details
#user ⇒ User
Returns User object.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/evss/dependents/retrieved_info.rb', line 15 class RetrievedInfo < Common::RedisStore include Common::CacheAside redis_config_key :evss_dependents_retrieve_response attr_accessor :user ## # Fetches retreived info for a user # # @param user [User] user object # @return [RetrievedInfo] an instance of the class with an assigned user # def self.for_user(user) ri = RetrievedInfo.new ri.user = user ri end ## # Creates a cached instance of a user's retrieved info # # @return [Hash] Retrieved info response body # def body do_cached_with(key: "evss_dependents_retrieve_#{@user.uuid}") do raw_response = EVSS::Dependents::Service.new(@user).retrieve EVSS::Dependents::RetrieveInfoResponse.new(raw_response.status, raw_response) end.response_body end ## # Deletes retrieved info cache # def delete self.class.delete("evss_dependents_retrieve_#{@user.uuid}") end end |
Class Method Details
.for_user(user) ⇒ RetrievedInfo
Fetches retreived info for a user
28 29 30 31 32 |
# File 'lib/evss/dependents/retrieved_info.rb', line 28 def self.for_user(user) ri = RetrievedInfo.new ri.user = user ri end |
Instance Method Details
#body ⇒ Hash
Creates a cached instance of a user’s retrieved info
39 40 41 42 43 44 |
# File 'lib/evss/dependents/retrieved_info.rb', line 39 def body do_cached_with(key: "evss_dependents_retrieve_#{@user.uuid}") do raw_response = EVSS::Dependents::Service.new(@user).retrieve EVSS::Dependents::RetrieveInfoResponse.new(raw_response.status, raw_response) end.response_body end |
#delete ⇒ Object
Deletes retrieved info cache
49 50 51 |
# File 'lib/evss/dependents/retrieved_info.rb', line 49 def delete self.class.delete("evss_dependents_retrieve_#{@user.uuid}") end |