activesupport 3.0.0.beta4 → 3.0.pre
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activesupport might be problematic. Click here for more details.
- data/CHANGELOG +1 -100
- data/lib/active_support.rb +4 -38
- data/lib/active_support/autoload.rb +28 -0
- data/lib/active_support/backtrace_cleaner.rb +9 -31
- data/lib/active_support/benchmarkable.rb +0 -1
- data/lib/active_support/buffered_logger.rb +1 -0
- data/lib/active_support/cache.rb +81 -436
- data/lib/active_support/cache/compressed_mem_cache_store.rb +13 -6
- data/lib/active_support/cache/file_store.rb +41 -139
- data/lib/active_support/cache/mem_cache_store.rb +75 -120
- data/lib/active_support/cache/memory_store.rb +27 -127
- data/lib/active_support/cache/strategy/local_cache.rb +58 -111
- data/lib/active_support/cache/synchronized_memory_store.rb +38 -2
- data/lib/active_support/callbacks.rb +48 -87
- data/lib/active_support/configurable.rb +18 -19
- data/lib/active_support/core_ext/array.rb +0 -1
- data/lib/active_support/core_ext/array/access.rb +1 -1
- data/lib/active_support/core_ext/array/conversions.rb +54 -29
- data/lib/active_support/core_ext/array/extract_options.rb +1 -16
- data/lib/active_support/core_ext/array/random_access.rb +5 -19
- data/lib/active_support/core_ext/array/wrap.rb +9 -13
- data/lib/active_support/core_ext/benchmark.rb +12 -0
- data/lib/active_support/core_ext/boolean.rb +1 -0
- data/lib/active_support/core_ext/boolean/conversions.rb +11 -0
- data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +0 -2
- data/lib/active_support/core_ext/class.rb +1 -1
- data/lib/active_support/core_ext/class/attribute_accessors.rb +27 -33
- data/lib/active_support/core_ext/class/delegating_attributes.rb +41 -35
- data/lib/active_support/core_ext/class/inheritable_attributes.rb +13 -22
- data/lib/active_support/core_ext/class/removal.rb +53 -0
- data/lib/active_support/core_ext/date.rb +7 -0
- data/lib/active_support/core_ext/date/calculations.rb +8 -30
- data/lib/active_support/core_ext/date/conversions.rb +2 -2
- data/lib/active_support/core_ext/date_time.rb +5 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +1 -2
- data/lib/active_support/core_ext/date_time/conversions.rb +5 -23
- data/lib/active_support/core_ext/enumerable.rb +9 -5
- data/lib/active_support/core_ext/exception.rb +47 -0
- data/lib/active_support/core_ext/file.rb +0 -1
- data/lib/active_support/core_ext/file/atomic.rb +2 -3
- data/lib/active_support/core_ext/float/rounding.rb +2 -3
- data/lib/active_support/core_ext/hash/conversions.rb +145 -65
- data/lib/active_support/core_ext/hash/deep_merge.rb +7 -6
- data/lib/active_support/core_ext/hash/except.rb +0 -8
- data/lib/active_support/core_ext/hash/indifferent_access.rb +0 -5
- data/lib/active_support/core_ext/hash/keys.rb +11 -10
- data/lib/active_support/core_ext/hash/slice.rb +0 -6
- data/lib/active_support/core_ext/integer.rb +1 -1
- data/lib/active_support/core_ext/integer/even_odd.rb +16 -0
- data/lib/active_support/core_ext/kernel.rb +1 -1
- data/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
- data/lib/active_support/core_ext/kernel/debugger.rb +2 -3
- data/lib/active_support/core_ext/kernel/reporting.rb +1 -2
- data/lib/active_support/core_ext/load_error.rb +30 -17
- data/lib/active_support/core_ext/logger.rb +1 -1
- data/lib/active_support/core_ext/module.rb +3 -5
- data/lib/active_support/core_ext/module/aliasing.rb +1 -1
- data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +1 -1
- data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
- data/lib/active_support/core_ext/module/attribute_accessors.rb +21 -25
- data/lib/active_support/core_ext/module/delegation.rb +10 -21
- data/lib/active_support/core_ext/module/inclusion.rb +30 -0
- data/lib/active_support/core_ext/module/introspection.rb +8 -8
- data/lib/active_support/core_ext/module/loading.rb +23 -0
- data/lib/active_support/core_ext/module/synchronization.rb +1 -2
- data/lib/active_support/core_ext/name_error.rb +1 -3
- data/lib/active_support/core_ext/nil.rb +1 -0
- data/lib/active_support/core_ext/nil/conversions.rb +5 -0
- data/lib/active_support/core_ext/object.rb +2 -6
- data/lib/active_support/core_ext/object/blank.rb +2 -20
- data/lib/active_support/core_ext/object/conversions.rb +16 -2
- data/lib/active_support/core_ext/object/duplicable.rb +1 -23
- data/lib/active_support/core_ext/object/extending.rb +77 -8
- data/lib/active_support/core_ext/object/instance_variables.rb +7 -0
- data/lib/active_support/core_ext/object/metaclass.rb +13 -0
- data/lib/active_support/core_ext/object/misc.rb +1 -0
- data/lib/active_support/core_ext/object/tap.rb +16 -0
- data/lib/active_support/core_ext/object/with_options.rb +0 -2
- data/lib/active_support/core_ext/proc.rb +4 -4
- data/lib/active_support/core_ext/regexp.rb +22 -0
- data/lib/active_support/core_ext/rexml.rb +1 -4
- data/lib/active_support/core_ext/string.rb +2 -3
- data/lib/active_support/core_ext/string/access.rb +2 -4
- data/lib/active_support/core_ext/string/bytesize.rb +5 -0
- data/lib/active_support/core_ext/string/conversions.rb +1 -36
- data/lib/active_support/core_ext/string/filters.rb +0 -29
- data/lib/active_support/core_ext/string/inflections.rb +12 -1
- data/lib/active_support/core_ext/string/interpolation.rb +92 -2
- data/lib/active_support/core_ext/string/iterators.rb +13 -0
- data/lib/active_support/core_ext/string/multibyte.rb +19 -16
- data/lib/active_support/core_ext/string/output_safety.rb +35 -101
- data/lib/active_support/core_ext/string/starts_ends_with.rb +14 -0
- data/lib/active_support/core_ext/string/xchar.rb +1 -1
- data/lib/active_support/core_ext/symbol.rb +1 -0
- data/lib/active_support/core_ext/symbol/to_proc.rb +14 -0
- data/lib/active_support/core_ext/time.rb +10 -0
- data/lib/active_support/core_ext/time/calculations.rb +7 -9
- data/lib/active_support/core_ext/time/conversions.rb +0 -1
- data/lib/active_support/core_ext/time/marshal_with_utc_flag.rb +22 -0
- data/lib/active_support/core_ext/uri.rb +4 -10
- data/lib/active_support/dependencies.rb +192 -179
- data/lib/active_support/deprecated_callbacks.rb +283 -0
- data/lib/active_support/deprecation/behaviors.rb +1 -1
- data/lib/active_support/deprecation/method_wrappers.rb +9 -10
- data/lib/active_support/deprecation/reporting.rb +1 -2
- data/lib/active_support/duration.rb +2 -6
- data/lib/active_support/hash_with_indifferent_access.rb +1 -9
- data/lib/active_support/inflections.rb +1 -1
- data/lib/active_support/inflector.rb +407 -4
- data/lib/active_support/json/backends/jsongem.rb +9 -12
- data/lib/active_support/json/decoding.rb +1 -16
- data/lib/active_support/json/encoding.rb +12 -42
- data/lib/active_support/locale/en.yml +1 -4
- data/lib/active_support/memoizable.rb +1 -1
- data/lib/active_support/message_encryptor.rb +0 -1
- data/lib/active_support/message_verifier.rb +5 -6
- data/lib/active_support/multibyte.rb +22 -7
- data/lib/active_support/multibyte/chars.rb +392 -164
- data/lib/active_support/multibyte/unicode_database.rb +71 -0
- data/lib/active_support/multibyte/utils.rb +7 -6
- data/lib/active_support/notifications.rb +113 -23
- data/lib/active_support/ordered_hash.rb +11 -35
- data/lib/active_support/ordered_options.rb +0 -6
- data/lib/active_support/rescuable.rb +4 -7
- data/lib/active_support/ruby/shim.rb +6 -4
- data/lib/active_support/test_case.rb +7 -2
- data/lib/active_support/testing/assertions.rb +0 -15
- data/lib/active_support/testing/declarative.rb +1 -1
- data/lib/active_support/testing/isolation.rb +19 -63
- data/lib/active_support/testing/performance.rb +337 -342
- data/lib/active_support/testing/setup_and_teardown.rb +29 -51
- data/lib/active_support/time.rb +3 -23
- data/lib/active_support/time_with_zone.rb +10 -5
- data/lib/active_support/values/time_zone.rb +84 -40
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/vendor.rb +16 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/blankslate.rb +113 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder.rb +13 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/blankslate.rb +20 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/css.rb +250 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xchar.rb +115 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlbase.rb +139 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlevents.rb +63 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlmarkup.rb +328 -0
- data/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE +20 -0
- data/lib/active_support/vendor/i18n-0.1.3/README.textile +20 -0
- data/lib/active_support/vendor/i18n-0.1.3/Rakefile +5 -0
- data/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec +27 -0
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb +204 -0
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb +215 -0
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb +53 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/all.rb +5 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +99 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +124 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb +1 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml +3 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +567 -0
- data/lib/active_support/vendor/memcache-client-1.7.5/lib/memcache.rb +1133 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo.rb +33 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone.rb +47 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone_info.rb +228 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Algiers.rb +55 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Cairo.rb +219 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Casablanca.rb +42 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Harare.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Monrovia.rb +22 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Nairobi.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Bogota.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Caracas.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chicago.rb +283 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chihuahua.rb +136 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Denver.rb +204 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Godthab.rb +161 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Guatemala.rb +27 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Halifax.rb +274 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Juneau.rb +194 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/La_Paz.rb +22 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Lima.rb +35 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Los_Angeles.rb +232 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mazatlan.rb +139 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mexico_City.rb +144 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Monterrey.rb +131 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/New_York.rb +282 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Phoenix.rb +30 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Regina.rb +74 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Santiago.rb +205 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Sao_Paulo.rb +171 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/St_Johns.rb +288 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Tijuana.rb +196 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Almaty.rb +67 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baghdad.rb +73 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baku.rb +161 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Bangkok.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Chongqing.rb +33 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Colombo.rb +30 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Dhaka.rb +27 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jakarta.rb +30 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kabul.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Karachi.rb +32 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kathmandu.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kolkata.rb +25 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuwait.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Magadan.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Muscat.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Rangoon.rb +24 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Riyadh.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Seoul.rb +34 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Shanghai.rb +35 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Singapore.rb +33 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Taipei.rb +59 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tashkent.rb +47 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tehran.rb +121 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tokyo.rb +30 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Urumqi.rb +33 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yerevan.rb +165 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Azores.rb +270 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Adelaide.rb +187 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Brisbane.rb +35 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Darwin.rb +29 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Hobart.rb +193 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Melbourne.rb +185 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Perth.rb +37 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Sydney.rb +185 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Etc/UTC.rb +16 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Athens.rb +185 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Belgrade.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Berlin.rb +188 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bratislava.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Brussels.rb +232 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bucharest.rb +181 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Budapest.rb +197 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Dublin.rb +276 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Helsinki.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Istanbul.rb +218 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Kiev.rb +168 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Lisbon.rb +268 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/London.rb +288 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Madrid.rb +211 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Minsk.rb +170 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Moscow.rb +181 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Paris.rb +232 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Prague.rb +187 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Riga.rb +176 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Rome.rb +215 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Skopje.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sofia.rb +173 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Stockholm.rb +165 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Tallinn.rb +172 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vienna.rb +183 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vilnius.rb +170 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Warsaw.rb +212 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Zagreb.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Auckland.rb +202 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Fiji.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Guam.rb +22 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Majuro.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Midway.rb +25 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Noumea.rb +25 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/info_timezone.rb +52 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone.rb +51 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone_info.rb +44 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/offset_rationals.rb +98 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/ruby_core_support.rb +56 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/time_or_datetime.rb +292 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone.rb +508 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_definition.rb +56 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_info.rb +40 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_offset_info.rb +94 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_period.rb +198 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_transition_info.rb +129 -0
- data/lib/active_support/version.rb +2 -3
- data/lib/active_support/whiny_nil.rb +7 -9
- data/lib/active_support/xml_mini.rb +1 -126
- data/lib/active_support/xml_mini/jdom.rb +0 -2
- data/lib/active_support/xml_mini/libxml.rb +86 -24
- data/lib/active_support/xml_mini/nokogiri.rb +24 -27
- data/lib/active_support/xml_mini/rexml.rb +1 -7
- metadata +191 -49
- data/lib/active_support/builder.rb +0 -6
- data/lib/active_support/core_ext/array/uniq_by.rb +0 -17
- data/lib/active_support/core_ext/class/attribute.rb +0 -67
- data/lib/active_support/core_ext/class/subclasses.rb +0 -55
- data/lib/active_support/core_ext/file/path.rb +0 -5
- data/lib/active_support/core_ext/integer/multiple.rb +0 -6
- data/lib/active_support/core_ext/kernel/singleton_class.rb +0 -13
- data/lib/active_support/core_ext/module/anonymous.rb +0 -24
- data/lib/active_support/core_ext/module/method_names.rb +0 -14
- data/lib/active_support/core_ext/module/reachable.rb +0 -10
- data/lib/active_support/core_ext/module/remove_method.rb +0 -6
- data/lib/active_support/core_ext/object/to_param.rb +0 -49
- data/lib/active_support/core_ext/object/to_query.rb +0 -27
- data/lib/active_support/core_ext/string/encoding.rb +0 -11
- data/lib/active_support/core_ext/string/exclude.rb +0 -6
- data/lib/active_support/core_ext/time/marshal.rb +0 -56
- data/lib/active_support/dependencies/autoload.rb +0 -50
- data/lib/active_support/i18n.rb +0 -8
- data/lib/active_support/inflector/inflections.rb +0 -211
- data/lib/active_support/inflector/methods.rb +0 -141
- data/lib/active_support/inflector/transliterate.rb +0 -97
- data/lib/active_support/json/backends/yajl.rb +0 -40
- data/lib/active_support/lazy_load_hooks.rb +0 -27
- data/lib/active_support/multibyte/unicode.rb +0 -393
- data/lib/active_support/notifications/fanout.rb +0 -93
- data/lib/active_support/notifications/instrumenter.rb +0 -56
- data/lib/active_support/railtie.rb +0 -100
- data/lib/active_support/xml_mini/libxmlsax.rb +0 -85
- data/lib/active_support/xml_mini/nokogirisax.rb +0 -83
@@ -1,12 +1,19 @@
|
|
1
1
|
module ActiveSupport
|
2
2
|
module Cache
|
3
3
|
class CompressedMemCacheStore < MemCacheStore
|
4
|
-
def
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
def read(name, options = nil)
|
5
|
+
if value = super(name, (options || {}).merge(:raw => true))
|
6
|
+
if raw?(options)
|
7
|
+
value
|
8
|
+
else
|
9
|
+
Marshal.load(ActiveSupport::Gzip.decompress(value))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def write(name, value, options = nil)
|
15
|
+
value = ActiveSupport::Gzip.compress(Marshal.dump(value)) unless raw?(options)
|
16
|
+
super(name, value, (options || {}).merge(:raw => true))
|
10
17
|
end
|
11
18
|
end
|
12
19
|
end
|
@@ -3,171 +3,73 @@ require 'active_support/core_ext/file/atomic'
|
|
3
3
|
module ActiveSupport
|
4
4
|
module Cache
|
5
5
|
# A cache store implementation which stores everything on the filesystem.
|
6
|
-
#
|
7
|
-
# FileStore implements the Strategy::LocalCache strategy which implements
|
8
|
-
# an in memory cache inside of a block.
|
9
6
|
class FileStore < Store
|
10
7
|
attr_reader :cache_path
|
11
8
|
|
12
|
-
|
13
|
-
ESCAPE_FILENAME_CHARS = /[^a-z0-9_.-]/i
|
14
|
-
UNESCAPE_FILENAME_CHARS = /%[0-9A-F]{2}/
|
15
|
-
|
16
|
-
def initialize(cache_path, options = nil)
|
17
|
-
super(options)
|
9
|
+
def initialize(cache_path)
|
18
10
|
@cache_path = cache_path
|
19
|
-
extend Strategy::LocalCache
|
20
|
-
end
|
21
|
-
|
22
|
-
def clear(options = nil)
|
23
|
-
root_dirs = Dir.entries(cache_path).reject{|f| ['.', '..'].include?(f)}
|
24
|
-
FileUtils.rm_r(root_dirs.collect{|f| File.join(cache_path, f)})
|
25
|
-
end
|
26
|
-
|
27
|
-
def cleanup(options = nil)
|
28
|
-
options = merged_options(options)
|
29
|
-
each_key(options) do |key|
|
30
|
-
entry = read_entry(key, options)
|
31
|
-
delete_entry(key, options) if entry && entry.expired?
|
32
|
-
end
|
33
11
|
end
|
34
12
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
13
|
+
# Reads a value from the cache.
|
14
|
+
#
|
15
|
+
# Possible options:
|
16
|
+
# - +:expires_in+ - the number of seconds that this value may stay in
|
17
|
+
# the cache.
|
18
|
+
def read(name, options = nil)
|
19
|
+
super do
|
20
|
+
file_name = real_file_path(name)
|
21
|
+
expires = expires_in(options)
|
22
|
+
|
23
|
+
if File.exist?(file_name) && (expires <= 0 || Time.now - File.mtime(file_name) < expires)
|
24
|
+
File.open(file_name, 'rb') { |f| Marshal.load(f) }
|
45
25
|
end
|
46
26
|
end
|
47
27
|
end
|
48
28
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
write(name, num, options)
|
56
|
-
num
|
57
|
-
else
|
58
|
-
nil
|
59
|
-
end
|
29
|
+
# Writes a value to the cache.
|
30
|
+
def write(name, value, options = nil)
|
31
|
+
super do
|
32
|
+
ensure_cache_path(File.dirname(real_file_path(name)))
|
33
|
+
File.atomic_write(real_file_path(name), cache_path) { |f| Marshal.dump(value, f) }
|
34
|
+
value
|
60
35
|
end
|
36
|
+
rescue => e
|
37
|
+
logger.error "Couldn't create cache directory: #{name} (#{e.message})" if logger
|
61
38
|
end
|
62
39
|
|
63
|
-
def
|
64
|
-
|
65
|
-
|
66
|
-
matcher = key_matcher(matcher, options)
|
67
|
-
search_dir(cache_path) do |path|
|
68
|
-
key = file_path_key(path)
|
69
|
-
delete_entry(key, options) if key.match(matcher)
|
70
|
-
end
|
40
|
+
def delete(name, options = nil)
|
41
|
+
super do
|
42
|
+
File.delete(real_file_path(name))
|
71
43
|
end
|
44
|
+
rescue SystemCallError => e
|
45
|
+
# If there's no cache, then there's nothing to complain about
|
72
46
|
end
|
73
47
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
if File.exist?(file_name)
|
79
|
-
entry = File.open(file_name) { |f| Marshal.load(f) }
|
80
|
-
if entry && !entry.expired? && !entry.expires_in && !self.options[:expires_in]
|
81
|
-
# Check for deprecated use of +:expires_in+ option from versions < 3.0
|
82
|
-
deprecated_expires_in = options[:expires_in]
|
83
|
-
if deprecated_expires_in
|
84
|
-
ActiveSupport::Deprecation.warn('Setting :expires_in on read has been deprecated in favor of setting it on write.', caller)
|
85
|
-
if entry.created_at + deprecated_expires_in.to_f <= Time.now.to_f
|
86
|
-
delete_entry(key, options)
|
87
|
-
entry = nil
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
entry
|
92
|
-
end
|
93
|
-
rescue
|
94
|
-
nil
|
95
|
-
end
|
96
|
-
|
97
|
-
def write_entry(key, entry, options)
|
98
|
-
file_name = key_file_path(key)
|
99
|
-
ensure_cache_path(File.dirname(file_name))
|
100
|
-
File.atomic_write(file_name, cache_path) {|f| Marshal.dump(entry, f)}
|
101
|
-
true
|
102
|
-
end
|
103
|
-
|
104
|
-
def delete_entry(key, options)
|
105
|
-
file_name = key_file_path(key)
|
106
|
-
if File.exist?(file_name)
|
107
|
-
begin
|
108
|
-
File.delete(file_name)
|
109
|
-
delete_empty_directories(File.dirname(file_name))
|
110
|
-
true
|
111
|
-
rescue => e
|
112
|
-
# Just in case the error was caused by another process deleting the file first.
|
113
|
-
raise e if File.exist?(file_name)
|
114
|
-
false
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
private
|
120
|
-
# Lock a file for a block so only one process can modify it at a time.
|
121
|
-
def lock_file(file_name, &block) # :nodoc:
|
122
|
-
if File.exist?(file_name)
|
123
|
-
File.open(file_name, 'r') do |f|
|
48
|
+
def delete_matched(matcher, options = nil)
|
49
|
+
super do
|
50
|
+
search_dir(@cache_path) do |f|
|
51
|
+
if f =~ matcher
|
124
52
|
begin
|
125
|
-
f
|
126
|
-
|
127
|
-
|
128
|
-
f.flock File::LOCK_UN
|
53
|
+
File.delete(f)
|
54
|
+
rescue SystemCallError => e
|
55
|
+
# If there's no cache, then there's nothing to complain about
|
129
56
|
end
|
130
57
|
end
|
131
|
-
else
|
132
|
-
yield
|
133
58
|
end
|
134
59
|
end
|
60
|
+
end
|
135
61
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
hash = Zlib.adler32(fname)
|
140
|
-
hash, dir_1 = hash.divmod(0x1000)
|
141
|
-
dir_2 = hash.modulo(0x1000)
|
142
|
-
fname_paths = []
|
143
|
-
# Make sure file name is < 255 characters so it doesn't exceed file system limits.
|
144
|
-
if fname.size <= 255
|
145
|
-
fname_paths << fname
|
146
|
-
else
|
147
|
-
while fname.size <= 255
|
148
|
-
fname_path << fname[0, 255]
|
149
|
-
fname = fname[255, -1]
|
150
|
-
end
|
151
|
-
end
|
152
|
-
File.join(cache_path, DIR_FORMATTER % dir_1, DIR_FORMATTER % dir_2, *fname_paths)
|
153
|
-
end
|
154
|
-
|
155
|
-
# Translate a file path into a key.
|
156
|
-
def file_path_key(path)
|
157
|
-
fname = path[cache_path.size, path.size].split(File::SEPARATOR, 4).last
|
158
|
-
fname.gsub(UNESCAPE_FILENAME_CHARS){|match| $1.ord.to_s(16)}
|
62
|
+
def exist?(name, options = nil)
|
63
|
+
super do
|
64
|
+
File.exist?(real_file_path(name))
|
159
65
|
end
|
66
|
+
end
|
160
67
|
|
161
|
-
|
162
|
-
def
|
163
|
-
|
164
|
-
if Dir.entries(dir).reject{|f| ['.', '..'].include?(f)}.empty?
|
165
|
-
File.delete(dir) rescue nil
|
166
|
-
delete_empty_directories(File.dirname(dir))
|
167
|
-
end
|
68
|
+
private
|
69
|
+
def real_file_path(name)
|
70
|
+
'%s/%s.cache' % [@cache_path, name.gsub('?', '.').gsub(':', '.')]
|
168
71
|
end
|
169
72
|
|
170
|
-
# Make sure a file path's directories exist.
|
171
73
|
def ensure_cache_path(path)
|
172
74
|
FileUtils.makedirs(path) unless File.exist?(path)
|
173
75
|
end
|
@@ -1,10 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'memcache'
|
3
|
-
rescue LoadError => e
|
4
|
-
$stderr.puts "You don't have memcache installed in your application. Please add it to your Gemfile and run bundle install"
|
5
|
-
raise e
|
6
|
-
end
|
7
|
-
require 'digest/md5'
|
1
|
+
require 'memcache'
|
8
2
|
|
9
3
|
module ActiveSupport
|
10
4
|
module Cache
|
@@ -18,9 +12,8 @@ module ActiveSupport
|
|
18
12
|
# and MemCacheStore will load balance between all available servers. If a
|
19
13
|
# server goes down, then MemCacheStore will ignore it until it goes back
|
20
14
|
# online.
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# an in memory cache inside of a block.
|
15
|
+
# - Time-based expiry support. See #write and the <tt>:expires_in</tt> option.
|
16
|
+
# - Per-request in memory cache for all communication with the MemCache server(s).
|
24
17
|
class MemCacheStore < Store
|
25
18
|
module Response # :nodoc:
|
26
19
|
STORED = "STORED\r\n"
|
@@ -30,8 +23,6 @@ module ActiveSupport
|
|
30
23
|
DELETED = "DELETED\r\n"
|
31
24
|
end
|
32
25
|
|
33
|
-
ESCAPE_KEY_CHARS = /[\x00-\x20%\x7F-\xFF]/
|
34
|
-
|
35
26
|
def self.build_mem_cache(*addresses)
|
36
27
|
addresses = addresses.flatten
|
37
28
|
options = addresses.extract_options!
|
@@ -47,145 +38,109 @@ module ActiveSupport
|
|
47
38
|
#
|
48
39
|
# If no addresses are specified, then MemCacheStore will connect to
|
49
40
|
# localhost port 11211 (the default memcached port).
|
50
|
-
#
|
51
|
-
# Instead of addresses one can pass in a MemCache-like object. For example:
|
52
|
-
#
|
53
|
-
# require 'memcached' # gem install memcached; uses C bindings to libmemcached
|
54
|
-
# ActiveSupport::Cache::MemCacheStore.new(Memcached::Rails.new("localhost:11211"))
|
55
41
|
def initialize(*addresses)
|
56
|
-
addresses = addresses.flatten
|
57
|
-
options = addresses.extract_options!
|
58
|
-
super(options)
|
59
|
-
|
60
42
|
if addresses.first.respond_to?(:get)
|
61
43
|
@data = addresses.first
|
62
44
|
else
|
63
|
-
|
64
|
-
UNIVERSAL_OPTIONS.each{|name| mem_cache_options.delete(name)}
|
65
|
-
@data = self.class.build_mem_cache(*(addresses + [mem_cache_options]))
|
45
|
+
@data = self.class.build_mem_cache(*addresses)
|
66
46
|
end
|
67
47
|
|
68
48
|
extend Strategy::LocalCache
|
69
|
-
extend LocalCacheWithRaw
|
70
49
|
end
|
71
50
|
|
72
|
-
# Reads multiple keys from the cache
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
51
|
+
# Reads multiple keys from the cache.
|
52
|
+
def read_multi(*keys)
|
53
|
+
@data.get_multi keys
|
54
|
+
end
|
55
|
+
|
56
|
+
def read(key, options = nil) # :nodoc:
|
57
|
+
super do
|
58
|
+
@data.get(key, raw?(options))
|
59
|
+
end
|
60
|
+
rescue MemCache::MemCacheError => e
|
61
|
+
logger.error("MemCacheError (#{e}): #{e.message}")
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
|
65
|
+
# Writes a value to the cache.
|
66
|
+
#
|
67
|
+
# Possible options:
|
68
|
+
# - <tt>:unless_exist</tt> - set to true if you don't want to update the cache
|
69
|
+
# if the key is already set.
|
70
|
+
# - <tt>:expires_in</tt> - the number of seconds that this value may stay in
|
71
|
+
# the cache. See ActiveSupport::Cache::Store#write for an example.
|
72
|
+
def write(key, value, options = nil)
|
73
|
+
super do
|
74
|
+
method = options && options[:unless_exist] ? :add : :set
|
75
|
+
# memcache-client will break the connection if you send it an integer
|
76
|
+
# in raw mode, so we convert it to a string to be sure it continues working.
|
77
|
+
value = value.to_s if raw?(options)
|
78
|
+
response = @data.send(method, key, value, expires_in(options), raw?(options))
|
79
|
+
response == Response::STORED
|
80
|
+
end
|
81
|
+
rescue MemCache::MemCacheError => e
|
82
|
+
logger.error("MemCacheError (#{e}): #{e.message}")
|
83
|
+
false
|
84
|
+
end
|
85
|
+
|
86
|
+
def delete(key, options = nil) # :nodoc:
|
87
|
+
super do
|
88
|
+
response = @data.delete(key, expires_in(options))
|
89
|
+
response == Response::DELETED
|
83
90
|
end
|
84
|
-
|
91
|
+
rescue MemCache::MemCacheError => e
|
92
|
+
logger.error("MemCacheError (#{e}): #{e.message}")
|
93
|
+
false
|
85
94
|
end
|
86
95
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
response = instrument(:increment, name, :amount => amount) do
|
94
|
-
@data.incr(escape_key(namespaced_key(name, options)), amount)
|
96
|
+
def exist?(key, options = nil) # :nodoc:
|
97
|
+
# Doesn't call super, cause exist? in memcache is in fact a read
|
98
|
+
# But who cares? Reading is very fast anyway
|
99
|
+
# Local cache is checked first, if it doesn't know then memcache itself is read from
|
100
|
+
super do
|
101
|
+
!read(key, options).nil?
|
95
102
|
end
|
96
|
-
|
103
|
+
end
|
104
|
+
|
105
|
+
def increment(key, amount = 1) # :nodoc:
|
106
|
+
response = instrument(:increment, key, :amount => amount) do
|
107
|
+
@data.incr(key, amount)
|
108
|
+
end
|
109
|
+
|
110
|
+
response == Response::NOT_FOUND ? nil : response
|
97
111
|
rescue MemCache::MemCacheError
|
98
112
|
nil
|
99
113
|
end
|
100
114
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
# to zero.
|
105
|
-
def decrement(name, amount = 1, options = nil) # :nodoc:
|
106
|
-
options = merged_options(options)
|
107
|
-
response = instrument(:decrement, name, :amount => amount) do
|
108
|
-
@data.decr(escape_key(namespaced_key(name, options)), amount)
|
115
|
+
def decrement(key, amount = 1) # :nodoc:
|
116
|
+
response = instrument(:decrement, key, :amount => amount) do
|
117
|
+
@data.decr(key, amount)
|
109
118
|
end
|
110
|
-
|
119
|
+
|
120
|
+
response == Response::NOT_FOUND ? nil : response
|
111
121
|
rescue MemCache::MemCacheError
|
112
122
|
nil
|
113
123
|
end
|
114
124
|
|
115
|
-
|
116
|
-
|
117
|
-
|
125
|
+
def delete_matched(matcher, options = nil) # :nodoc:
|
126
|
+
# don't do any local caching at present, just pass
|
127
|
+
# through and let the error happen
|
128
|
+
super
|
129
|
+
raise "Not supported by Memcache"
|
130
|
+
end
|
131
|
+
|
132
|
+
def clear
|
118
133
|
@data.flush_all
|
119
134
|
end
|
120
135
|
|
121
|
-
# Get the statistics from the memcached servers.
|
122
136
|
def stats
|
123
137
|
@data.stats
|
124
138
|
end
|
125
139
|
|
126
|
-
protected
|
127
|
-
# Read an entry from the cache.
|
128
|
-
def read_entry(key, options) # :nodoc:
|
129
|
-
deserialize_entry(@data.get(escape_key(key), true))
|
130
|
-
rescue MemCache::MemCacheError => e
|
131
|
-
logger.error("MemCacheError (#{e}): #{e.message}") if logger
|
132
|
-
nil
|
133
|
-
end
|
134
|
-
|
135
|
-
# Write an entry to the cache.
|
136
|
-
def write_entry(key, entry, options) # :nodoc:
|
137
|
-
method = options && options[:unless_exist] ? :add : :set
|
138
|
-
value = options[:raw] ? entry.value.to_s : entry
|
139
|
-
expires_in = options[:expires_in].to_i
|
140
|
-
if expires_in > 0 && !options[:raw]
|
141
|
-
# Set the memcache expire a few minutes in the future to support race condition ttls on read
|
142
|
-
expires_in += 5.minutes
|
143
|
-
end
|
144
|
-
response = @data.send(method, escape_key(key), value, expires_in, options[:raw])
|
145
|
-
response == Response::STORED
|
146
|
-
rescue MemCache::MemCacheError => e
|
147
|
-
logger.error("MemCacheError (#{e}): #{e.message}") if logger
|
148
|
-
false
|
149
|
-
end
|
150
|
-
|
151
|
-
# Delete an entry from the cache.
|
152
|
-
def delete_entry(key, options) # :nodoc:
|
153
|
-
response = @data.delete(escape_key(key))
|
154
|
-
response == Response::DELETED
|
155
|
-
rescue MemCache::MemCacheError => e
|
156
|
-
logger.error("MemCacheError (#{e}): #{e.message}") if logger
|
157
|
-
false
|
158
|
-
end
|
159
|
-
|
160
140
|
private
|
161
|
-
def
|
162
|
-
|
163
|
-
key = "#{key[0, 213]}:md5:#{Digest::MD5.hexdigest(key)}" if key.size > 250
|
164
|
-
key
|
165
|
-
end
|
166
|
-
|
167
|
-
def deserialize_entry(raw_value)
|
168
|
-
if raw_value
|
169
|
-
entry = Marshal.load(raw_value) rescue raw_value
|
170
|
-
entry.is_a?(Entry) ? entry : Entry.new(entry)
|
171
|
-
else
|
172
|
-
nil
|
173
|
-
end
|
141
|
+
def raw?(options)
|
142
|
+
options && options[:raw]
|
174
143
|
end
|
175
|
-
|
176
|
-
# Provide support for raw values in the local cache strategy.
|
177
|
-
module LocalCacheWithRaw # :nodoc:
|
178
|
-
protected
|
179
|
-
def write_entry(key, entry, options) # :nodoc:
|
180
|
-
retval = super
|
181
|
-
if options[:raw] && local_cache && retval
|
182
|
-
raw_entry = Entry.new(entry.value.to_s)
|
183
|
-
raw_entry.expires_at = entry.expires_at
|
184
|
-
local_cache.write_entry(key, raw_entry, options)
|
185
|
-
end
|
186
|
-
retval
|
187
|
-
end
|
188
|
-
end
|
189
144
|
end
|
190
145
|
end
|
191
146
|
end
|