Commit Graph

135 Commits

Author SHA1 Message Date
Tara Scherner de la Fuente
926a24a751 remove args from assert_nothing_raised in tests 2016-02-22 22:56:23 -08:00
Kasper Timm Hansen
c4a46fa781 Revert "Instrument read_multi".
Reevaluating the log output generated from this instrumentation,
we've found that it wasn't all that useful in practice.

```
Caches multi read:
- views/david/2/4184ab71db6849621a4d8820fcd2c0ad
- views/david/2/4184ab71db6849621a4d8820fcd2c0ad
- views/david/3/4184ab71db6849621a4d8820fcd2c0ad
- views/david/3/4184ab71db6849621a4d8820fcd2c0ad
```

If rendering many templates the output is inscrutable, and it's impossible
to see how many cache misses there were.

Revert ca6aba7f30 and implement a better way later.
2016-02-20 17:35:52 +01:00
Godfrey Chan
2b90048395 Merge pull request #22278 from poporul/master
Allow to store .keep file in cache directory
2016-01-15 10:32:30 -08:00
yui-knk
912093d01e Suppress warning ambiguous first argument
Suppress warning (warning: ambiguous first argument; put
parentheses or a space even after `/' operator)
2015-12-20 22:15:56 +09:00
Robin Clowers
d27d6c84fd Fix cache fetch miss notification order
Fixes https://github.com/rails/rails/issues/22477.

When I improved the caching instrumentation in
edd33c08d98723ae9bb89cf7f019277117ed6414, I inadvertently changed the
order of AS notifications when there is a cache miss.
2015-12-02 21:27:29 -08:00
Michael Grosser
a8f773b057 add deprecations for a smooth transition after #22215 2015-11-19 20:49:37 -08:00
Alexey Pokhozhaev
4f3e868384 Allow to store .keep file in cache directory 2015-11-13 01:46:08 +03:00
Michael Grosser
a481f07817 send normalized keys to the cache backends so they do not need to manage this themselves 2015-11-10 21:12:30 -08:00
Michael Grosser
e401a6bb25 do not override fetch on local cache
fetch is supposed to behave differently, this was a mistake merged in

https://github.com/rails/rails/pull/22194
2015-11-07 08:38:01 -08:00
Sean Griffin
cb67c81933 Merge pull request #22194 from grosser/grosser/read-nil
cache nil replies from backend cache so misses are fast too
2015-11-05 19:21:13 -07:00
Michael Grosser
b9fb0f2623 cache nil replies from backend cache so misses are fast too 2015-11-05 17:47:40 -08:00
Sean Griffin
6c61ae816a Merge pull request #11872 from AvnerCohen/log_namespace
When testing cache issues, it is useful to log the actual key, including namespace
2015-10-30 09:44:54 -06:00
Sean Griffin
28129174f0 Merge pull request #19889 from cedrics/long-uri-encoded-keys
FileStore: Long cache keys may result in too long paths due to encoding
2015-10-20 17:03:48 -06:00
Robin Clowers
a948490b9c Add test cases for Cache#fetch instrumentation 2015-09-14 20:07:58 -07:00
Ronak Jangir
2f28e5b641 Removed use of mocha in active_support 2015-07-10 01:58:46 +05:30
Aaron Patterson
17439e3a40 remove bad test. 2015-06-25 16:08:16 -07:00
Avner Cohen
f654d658f2 When logging Cache key, in debug mode, also log namespace, to create the full key that actually used by the underline cache implementation 2015-06-23 23:07:19 +03:00
Ronak Jangir
81d2ce96d0 Removed mocha stubbing in active_support 2015-06-07 19:18:58 +05:30
Kasper Timm Hansen
afb6a2c08d Avoid E constant clashing with Minitest defined version.
Minitest sets an E constant to an empty string to save GC time.
This clashes with autoloading tests which define an E constant.
2015-05-22 23:30:08 +02:00
Cedric Sohrauer
2b5a8bc186 when checking for too long cache keys used the uri encoded fname 2015-04-24 15:36:40 +02:00
Kohei Suzuki
16d7cfb177 Allow AS::Cache::FileStore#clear without cache directory
Currently `Rails.cache.clear` raises Errno::ENOENT if it's run just
after cloning a new Rails project. It should succeed without removing
files or directories.
2015-04-09 00:04:56 +09:00
Matt Wilde
23767c0c41 Skip the :race_condition_ttl branch if the option is 0 or nil. This fixes an issue with the redis cache, where this code will sometimes throw an error out of SETEX when passing 0 as the expires_at. 2015-03-11 15:14:10 -07:00
Arthur Neves
5333393534 Remove not needed .tap 2015-03-02 11:20:47 -05:00
Rafael Mendonça França
2675a57fc3 Do not output in the console
[Robin Dupret + Rafael Mendonça França]
2015-03-02 12:04:37 -03:00
Kasper Timm Hansen
ca6aba7f30 Instrument read_multi.
Adds `read_multi` instrumentation formatted as:

Caches multi read:
- views/david/2/4184ab71db6849621a4d8820fcd2c0ad
- views/david/2/4184ab71db6849621a4d8820fcd2c0ad
- views/david/3/4184ab71db6849621a4d8820fcd2c0ad
- views/david/3/4184ab71db6849621a4d8820fcd2c0ad
2015-02-21 16:06:57 +01:00
Rafael Mendonça França
41d72ce372 Remove conversion code for old Rails cache entry
This code was there just to convert entries generated in Rails
4.0.0.beta1 applications to a supported format.

It is almost unlikely that any existent application have this cache
entry format in their caches at the point that Rails 5 will be released
so we don't need this code anymore.
2015-01-01 22:31:27 -03:00
Rafael Mendonça França
ddd0a22133 Check by @v before converting the entry on expired?
We should convert when @v is defined not @value.

The test was calling value first that already converts the entry so we
are not catching this bug.
2015-01-01 22:28:07 -03:00
Matthew Draper
d2d003e8f8 Keep the first string we fetch
Otherwise, it's possible for GC to run in between, and fail the test.
2014-08-27 01:04:56 +09:30
Zuhao Wan
023d14ecbb Create with_env helper for tests. 2014-06-22 20:31:34 +08:00
Adam Panzer
9010274627 fix error with long keys in ActiveSupport::Cache::FileStore 2014-06-10 10:53:48 -07:00
Parker Selbert
c046e60965 Return a hash rather than array from fetch_multi
The current implementation of `fetch_multi` returns an array and has no
means to easily backtrack which names yielded which results. By changing
the return value to a Hash we retain the name information. Hash#values
can be used on the response if only the values are needed.
2014-02-26 20:31:46 -06:00
Aaron Patterson
e176353b71 clear cache on body close so that cache remains during rendering
fixes #13547

The body may use the local cache during rendering.  `call`ing the app
doesn't mean that rendering is finished, so we need to wait until
`close` is called on the body.
2014-01-08 15:48:19 -08:00
Arthur Neves
e7f56a7fe8 Raise if MemCacheStore doenst receive a Dalli obj
:mem_cache_store should receive a list of hosts or a dalli client,
otherwise raise it.
Also adding a changelog.
2014-01-03 16:39:50 -05:00
Arthur Neves
98458eea42 mem_cache_store requires dalli, so only accept dalli/client
:mem_cache_store require dalli, rescue Dalli exceptions, and follow Dalli API.
Memcached gem, for instance, doesnt work anymore, as the API are different.

As we already require one client, we should make sure that client works, and not accept others, and if someone wants to use another memcache client they can write their own store adapter.
2014-01-03 15:39:33 -05:00
Rafael Mendonça França
f18cf8e488 Merge pull request #11785 from grosser/grosser/file-unless-exist
support :unless_exist for FileCache

Conflicts:
	activesupport/CHANGELOG.md
	activesupport/test/caching_test.rb
2013-10-28 19:09:22 -02:00
Murray Steele
accd4926cc Fix FileStore#cleanup to no longer rely on missing each_key method 2013-09-11 13:58:40 +01:00
grosser
c17bd7476a support :unless_exist for FileCache 2013-08-30 12:53:35 +02:00
Simeon Simeonov
51d9b9a821 [Fixes #11512] improves cache size calculation in ActiveSupport::Cache::MemoryStore
Previously, the cache size of `ActiveSupport::Cache::MemoryStore` was calculated
as the sum of the size of its entries, ignoring the size of keys and any data
structure overhead. This could lead to the calculated cache size sometimes being
10-100x smaller than the memory used, e.g., in the case of small values.

The size of a key/entry pair is now calculated via `#cached_size`:

    def cached_size(key, entry)
      key.to_s.bytesize + entry.size + PER_ENTRY_OVERHEAD
    end

The value of `PER_ENTRY_OVERHEAD` is 240 bytes based on an [empirical
estimation](https://gist.github.com/ssimeonov/6047200) for 64-bit MRI on
1.9.3 and 2.0.

Fixes GH#11512 https://github.com/rails/rails/issues/11512
2013-07-22 09:53:03 -04:00
Jade Tucker
8471fc0363 Explicitly test for true and false. 2013-07-07 18:59:32 -07:00
Daniel Schierbeck
36d41a15c3 Allow fetching multiple values from the cache at once
Add a simple API for fetching a list of entries from the cache, where
any missing entries are computed by a supplied block.
2013-05-06 11:38:51 +02:00
Sam Ruby
8efc87c14e switch (and lazily convert) ivar names to 3.x 2013-04-16 13:18:52 -04:00
Anupam Choudhury
975234c680 Fixed typo 2013-04-10 15:13:10 +05:30
Vipul A M
8778e1c4af Fix typo in DependenciesTestHelpers module name 2013-03-12 10:33:32 +05:30
Charles Jones
b8837066dc Fix deletion of empty directories:
1. When comparing the directory to delete against the top level
   cache_path, use File.realpath to make sure we aren't comparing two
   unequal strings that point to the same path. This occurs, for
   example, when cache_path has a trailing slash, which it does in the
   default Rails configuration. Since the input to
   delete_empty_directories never has a trailing slash, the comparison
   will never be true and the top level cache directory (and above) may
   be deleted. However…

2. File.delete raises EPERM when trying to delete a directory, so no
   directories have ever been deleted. Changing the code to Dir.delete
   fixes that.
2013-02-25 18:54:44 -06:00
Yves Senn
947e1d5e85 deprecate assert_blank and assert_present.
They don't add any benefits over `assert object.blank?`
and `assert object.present?`
2013-01-05 18:04:52 +01:00
Uriel Katz
9ee0ffb360 Patched Marshal#load to work with constant autoloading (active_support/dependecies.rb) (issue #8167) 2012-12-01 14:00:16 +02:00
Noah Hendrix
96f5ceaafb make the cache test more @tenderlove(ing) and not depend on internal implentation 2012-10-23 18:42:37 -07:00
Noah Hendrix
81b7112565 pass the key to the block in cache.fetch on misses 2012-10-23 00:04:42 -07:00
Aaron Patterson
b91a90e496 adding a test for b21f24d9807bd161af947cf0f0cc440c9adffb73 2012-10-11 18:26:52 -07:00
Arun Agrawal
21051676fc warning fixed: (...) interpreted as grouped expression 2012-10-01 18:25:19 +05:30