{:$JohnnyCache::ClassMethods#cacheo:$YARD::CodeObjects::MethodObject: @dynamicT:@explicitT:@docstringIC:YARD::Docstring" :@ref_tags[: @summary0: @tags[o:YARD::Tags::Tag :@tag_name"see: @types0: @name"JohnnyCache#cache: @text0: @object@:@hash_flagF:@line_rangeo: Range:endiP: beginiP: exclF: @all"@see JohnnyCache#cache;@: @source"8def cache(*args) MethodCache.new(self, *args) end: @scope: instance:@signature"def cache(*args); [:@docstring_extra0: @lineiQ;: cache: @path"$JohnnyCache::ClassMethods#cache:@visibility: public:@source_type: ruby:@parameters[[" *args0:@namespaceo:$YARD::CodeObjects::ModuleObject;T:@instance_mixinsIC:&YARD::CodeObjects::CodeObjectList[: @owner@; IC; " ; [; 0; [;F;";@:@class_mixinsIC;+[;,@; [: @groups[;""JohnnyCache::ClassMethods;:ClassMethods;#;$:@attributesIC:SymbolHash{: classIC;1{:@symbolize_valueT;IC;1{;3T;3T:@childrenIC;+[@;,@;%;&: @aliases{;(o;);*IC;+[;,@%; IC; "include JohnnyCache ; [; 0; [o; ;" example;0;";"class User < ActiveRecord::Base include JohnnyCache def expensive_method(val) sleep 120 return val end end user = User.last user.expensive_method(22) # => 22 user.cache.expensive_method(22) # => 22 Benchmark.measure do user.expensive_method(22) end.real # => 120.00037693977356 Benchmark.measure do user.cache.expensive_method(22) end.real # => 0.000840902328491211 # SOOOOOOOO FAST!!;@%o; ;"see;0;"JohnnyCache#cache;"More info on cache options;@%;F;o;;i,;i ;F;"include JohnnyCache @example class User < ActiveRecord::Base include JohnnyCache def expensive_method(val) sleep 120 return val end end user = User.last user.expensive_method(22) # => 22 user.cache.expensive_method(22) # => 22 Benchmark.measure do user.expensive_method(22) end.real # => 120.00037693977356 Benchmark.measure do user.cache.expensive_method(22) end.real # => 0.000840902328491211 # SOOOOOOOO FAST!! @see JohnnyCache#cache More info on cache options ;@%;-IC;+[o:YARD::CodeObjects::Proxy :@origname"ActiveSupport::Concern:@orignamespace@%;: Concern: @obj0;(o;6 ;70;80;:ActiveSupport;:0;(@%: @imethod0;<0;,@%; [;.[;0;""JohnnyCache;:JohnnyCache;#;$;0IC;1{;2IC;1{;3T;IC;1{;3T;3T;4IC;+[ o:&YARD::CodeObjects::ConstantObject;T; IC; " ; [; 0; [;F;";@?;"STORE = nil || Rails.cache: @value"nil || Rails.cache;"STORE = nil || Rails.cache; [; i/;""JohnnyCache::STORE;: STORE;#;$;%;&;(@%:@current_file_has_commentsF: @files[["lib/johnny_cache.rbi/o;;T;T; IC; " ; [; 0; [ o:YARD::Tags::OverloadTag ;" overload; IC; " ; [; 0; [;F;";@L;" cache;0;;!;'[;0;@Lo;C ;" overload; IC; " ; [; 0; [;F;";@L;"cache(options = {});0;;!;'[[: options"{};0;@Lo;C ;" overload; IC; " ; [; 0; [;F;";@L;"$cache(cache_operation = :fetch);0;;!;'[[:cache_operation" :fetch;0;@Lo;C ;" overload; IC; "eCreates a MethodCache instance that performs the given cache operation on the method it receives ; [; 0; [o; ;" param;[" Symbol;"cache_operation;"G(:fetch) The method called on the cache (:write, :read, or :fetch);0o; ;" param;[" Hash;" options;"6Optional hash that gets passed to the cache store;0;F;" Creates a MethodCache instance that performs the given cache operation on the method it receives @param [Symbol] cache_operation (:fetch) The method called on the cache (:write, :read, or :fetch) @param [Hash] options Optional hash that gets passed to the cache store;@L;"2cache(cache_operation = :fetch, options = {});0;;!;'[[;E" :fetch[;D"{};0;@Lo; ;" example;0;";"Auser = User.last # cache user.cache.some_method # cache(options) user.cache(:expires_in => 1.minutes).some_method # cache(cache_operation) user.cache(:fetch).some_method user.cache(:read).some_method user.cache(:write).some_method # cache(cache_operation, options) user.cache(:write, :expires_in 2.minutes).some_method;@L;F;o;;iI;i2;F;"@overload cache @overload cache(options = {}) @overload cache(cache_operation = :fetch) @overload cache(cache_operation = :fetch, options = {}) Creates a MethodCache instance that performs the given cache operation on the method it receives @param [Symbol] cache_operation (:fetch) The method called on the cache (:write, :read, or :fetch) @param [Hash] options Optional hash that gets passed to the cache store @example user = User.last # cache user.cache.some_method # cache(options) user.cache(:expires_in => 1.minutes).some_method # cache(cache_operation) user.cache(:fetch).some_method user.cache(:read).some_method user.cache(:write).some_method # cache(cache_operation, options) user.cache(:write, :expires_in 2.minutes).some_method;@L;"8def cache(*args) MethodCache.new(self, *args) end;;;"def cache(*args); [;0; iJ;;!;""JohnnyCache#cache;#;$;%;&;'[[" *args0;(@%;AT;B[[@KiJ@o:#YARD::CodeObjects::ClassObject;T;*IC;+[;,@; IC; " ; [; 0; [;F;";@:@superclasso;6 ;70;80;: Object;:0;(o:"YARD::CodeObjects::RootObject;*IC;+[;,@; IC; " ; [; 0; [;F;";@;-IC;+[;,@; [;.[;"";: root;#;$;0IC;1{;2IC;1{;3T;IC;1{;3T;3T;4IC;+[@%;,@;%;&;5{;(0;AF;B[;<0;-IC;+[;,@; [;.[;""JohnnyCache::MethodCache;:MethodCache;#;$;0IC;1{;2IC;1{;3T;IC;1{ ;DIC;1{: writeo;;T; IC; "Sets the attribute options ; [; 0; [o; ;" param;0;" value;"/the value to set the attribute options to.;@;F;"WSets the attribute options @param value the value to set the attribute options to.;@;"/def options=(value) @options = value end;;;"def options=(value); [;0;: options=;""&JohnnyCache::MethodCache#options=;#;$;%;&;'[[" value0;(@;AF;B[[@Ki[: reado;;T; IC; "+Returns the value of attribute options ; [; 0; [;F;"+Returns the value of attribute options;@;"def options @options end;;;"def options; [;0;;D;""%JohnnyCache::MethodCache#options;#;$;%;&;'[;(@;AF;B[[@Ki[;3T:caller_objectIC;1{;Lo;;T; IC; "%Sets the attribute caller_object ; [; 0; [o; ;" param;0;" value;"5the value to set the attribute caller_object to.;@;F;"cSets the attribute caller_object @param value the value to set the attribute caller_object to.;@;";def caller_object=(value) @caller_object = value end;;;"def caller_object=(value); [;0;:caller_object=;"",JohnnyCache::MethodCache#caller_object=;#;$;%;&;'[[" value0;(@;AF;B[[@Ki[;No;;T; IC; "1Returns the value of attribute caller_object ; [; 0; [;F;"1Returns the value of attribute caller_object;@;"+def caller_object @caller_object end;;;"def caller_object; [;0;;O;""+JohnnyCache::MethodCache#caller_object;#;$;%;&;'[;(@;AF;B[[@Ki[;3T: argsIC;1{;Lo;;T; IC; "Sets the attribute args ; [; 0; [o; ;" param;0;" value;",the value to set the attribute args to.;@;F;"QSets the attribute args @param value the value to set the attribute args to.;@;")def args=(value) @args = value end;;;"def args=(value); [;0;: args=;""#JohnnyCache::MethodCache#args=;#;$;%;&;'[[" value0;(@;AF;B[[@Ki[;No;;T; IC; "(Returns the value of attribute args ; [; 0; [;F;"(Returns the value of attribute args;@;"def args @args end;;;" def args; [;0;;Q;"""JohnnyCache::MethodCache#args;#;$;%;&;'[;(@;AF;B[[@Ki[;3T: methodIC;1{;Lo;;T; IC; "Sets the attribute method ; [; 0; [o; ;" param;0;" value;".the value to set the attribute method to.;@ ;F;"USets the attribute method @param value the value to set the attribute method to.;@ ;"-def method=(value) @method = value end;;;"def method=(value); [;0;: method=;""%JohnnyCache::MethodCache#method=;#;$;%;&;'[[" value0;(@;AF;B[[@Ki[;No;;T; IC; "*Returns the value of attribute method ; [; 0; [;F;"*Returns the value of attribute method;@;"def method @method end;;;"def method; [;0;;S;""$JohnnyCache::MethodCache#method;#;$;%;&;'[;(@;AF;B[[@Ki[;3T;EIC;1{;Lo;;T; IC; "'Sets the attribute cache_operation ; [; 0; [o; ;" param;0;" value;"7the value to set the attribute cache_operation to.;@);F;"gSets the attribute cache_operation @param value the value to set the attribute cache_operation to.;@);"?def cache_operation=(value) @cache_operation = value end;;;" def cache_operation=(value); [;0;:cache_operation=;"".JohnnyCache::MethodCache#cache_operation=;#;$;%;&;'[[" value0;(@;AF;B[[@Ki[;No;;T; IC; "3Returns the value of attribute cache_operation ; [; 0; [;F;"3Returns the value of attribute cache_operation;@;;"/def cache_operation @cache_operation end;;;"def cache_operation; [;0;;E;""-JohnnyCache::MethodCache#cache_operation;#;$;%;&;'[;(@;AF;B[[@Ki[;3T;3T;3T;4IC;+[@@@ @@@@@@)@;o;;T;T; IC; " ; [; 0; [o; ;" return;["MethodCache;0;""a new instance of MethodCache;@H;F;";@H;"\def initialize(caller_object, *method_cache_args) cache_operation = method_cache_args.map {|x| x if x.is_a? Symbol }.compact.first options = method_cache_args.map {|x| x if x.is_a? Hash }.compact.first self.cache_operation = cache_operation||:fetch self.options = options self.caller_object = caller_object end;;;"6def initialize(caller_object, *method_cache_args); [; i];:initialize;""(JohnnyCache::MethodCache#initialize;#;$;%;&;'[["caller_object0["*method_cache_args0;(@;AF;B[[@Ki]o;;T;T; IC; "VUses keytar to create a key based on the method and caller if no method_key exits ; [; 0; [o; ;"see;0;"&http://github.com/schneems/keytar;"Keytar, it builds keys;@]o; ;" return;0;0;""the key used to set the cache;@]o; ;" example;0;";"cache = User.find(263619).cache # => # cache.method = "foo" # => "foo" cache.key # => "users:foo:263619";@];F;o;;ik;ie;F;"sUses keytar to create a key based on the method and caller if no method_key exits @see http://github.com/schneems/keytar Keytar, it builds keys @return the key used to set the cache @example cache = User.find(263619).cache # => # cache.method = "foo" # => "foo" cache.key # => "users:foo:263619";@];"def key key_method = "#{method}_key".to_sym key = caller_object.send key_method, *args if caller_object.respond_to? key_method key ||= caller_object.build_key(:name => method, :args => args) end;;;" def key; [;0; il;:key;""!JohnnyCache::MethodCache#key;#;$;%;&;'[;(@;AT;B[[@Kilo;;T;T; IC; "7Calls the cache based on the given cache_operation ; [; 0; [o; ;" param;[" Hash;" options;"*Options are passed to the cache store;@uo; ;"see;0;"Thttp://api.rubyonrails.org/classes/ActionController/Caching.html#method-i-cache;"Rails.cache documentation;@u;F;o;;it;ir;F;"Calls the cache based on the given cache_operation @param [Hash] options Options are passed to the cache store @see http://api.rubyonrails.org/classes/ActionController/Caching.html#method-i-cache Rails.cache documentation;@u;"def call_cache_operation(options = {}) if cache_operation == :fetch JohnnyCache::STORE.fetch(key, options) do caller_object.send method.to_sym, *args end elsif cache_operation == :read JohnnyCache::STORE.read(key, options) elsif cache_operation == :write val = caller_object.send method.to_sym, *args JohnnyCache::STORE.write(key, val, options) end end;;;"+def call_cache_operation(options = {}); [;0; iu;:call_cache_operation;""2JohnnyCache::MethodCache#call_cache_operation;#;$;%;&;'[[" options"{};(@;AT;B[[@Kiuo;;T;T; IC; "yMethods caught by method_missing are passed to the caller_object and used to :write, :read, or :fetch from the cache ; [; 0; [o; ;"see;0;"JohnnyCache#cache;0;@;F;o;;i;i};F;"Methods caught by method_missing are passed to the caller_object and used to :write, :read, or :fetch from the cache @see JohnnyCache#cache;@;"def method_missing(method, *args, &blk) if caller_object.respond_to? method self.method = method self.args = args call_cache_operation(options) else super end end;;;",def method_missing(method, *args, &blk); [;0; i;:method_missing;"",JohnnyCache::MethodCache#method_missing;#;$;%;&;'[[" method0[" *args0[" &blk0;(@;AT;B[[@Ki;,@;%;&;5{;(@%;AF;B[[@KiZ;,@%;%;&;5{;(@;AT;B[[@Ki-;AF;B[[@KiO;AT;B[[@KiQ:+JohnnyCache::MethodCache#caller_object@:%JohnnyCache::MethodCache#options@;J@:"JohnnyCache::MethodCache#args@:2JohnnyCache::MethodCache#call_cache_operation@u:!JohnnyCache::MethodCache#key@]:,JohnnyCache::MethodCache#caller_object=@:#JohnnyCache::MethodCache#args=@:,JohnnyCache::MethodCache#method_missing@:&JohnnyCache::MethodCache#options=@:JohnnyCache::MethodCache@:$JohnnyCache::MethodCache#method@:JohnnyCache#cache@L:JohnnyCache::ClassMethods@:%JohnnyCache::MethodCache#method=@ :-JohnnyCache::MethodCache#cache_operation@;;=@%:JohnnyCache::STORE@?:(JohnnyCache::MethodCache#initialize@H:.JohnnyCache::MethodCache#cache_operation=@)