class Simple
include CacheClassMethods
end
# s = Simple.new
# s.cached?
# s.cache_record
# s.get_cached_record
# s.cache_key
# s.cache_name
# s.as_serialized
# s.bust_cache
class AwesomeModel < ActiveRecord::Base
include CacheClassMethods
cache_self prefix: :secret_hash, key: :name, serializer: AdvancedSerializer
cache_collection :cool_things, as: :awesome_things, serializer: AwesomeThingsSerializer
has_many :cool_things
def name
"Evan"
end
def secret_hash
"youthinkyoucool"
end
end
# a = AwesomeModel.new
## Collection
# a.awesome_things
# a.awesome_things_count
## Self cache
# s = AwesomeModel.new
# s.cached?
# s.cache_record
# s.get_cached_record
# s.cache_key
# s.cache_name
# s.as_serialized
# s.bust_cache