Commit Graph

81 Commits

Author SHA1 Message Date
Aaron Patterson
6a79aa7f81 skip the memcache tests if the memcache server is not up 2012-08-22 15:42:48 -07:00
Guillermo Iguaran
bd680e3f5f Add test to cover increment/decrement of non-existing key in MemCacheStore 2012-08-17 22:22:55 -05:00
Guillermo Iguaran
82663306f4 Replace deprecated memcache-client gem with dalli in ActiveSupport::Cache::MemCacheStore
memcache-client was deprecated in favour of dalli in 2010.
2012-08-17 22:22:55 -05:00
Michael Koziarski
e44009aa2b Merge pull request #5125 from winston/log_exception_when_cache_read_fails
#read_entry in ActiveSupport::Cache::FileStore should log details of the exception when an exception is thrown
2012-05-21 19:02:48 -07:00
grosser
b5005b6259 add unless_exist option to memory store 2012-05-10 08:19:45 -07:00
Aaron Patterson
7a3e43cc58 Merge pull request #4452 from tapajos/e5425c8f68fbb720fcbf4b14e1f154ac27dbbbed
Fix cache (FileStore) clear to keep .gitkeep.
2012-05-03 15:56:54 -07:00
Arun Agrawal
40c38d969c warning removed: (...) interpreted as grouped expression 2012-03-31 16:31:07 +05:30
Aaron Patterson
ad95a61b62 Merge pull request #4911 from Floppy/master
Reduce FILENAME_MAX_SIZE in ActiveSupport::Cache::FileStore
2012-03-30 17:43:55 -07:00
Erich Menge
be623677a3 Allow retrieve_cache_key to work on collections such as ActiveRecord::Relation. 2012-03-12 12:29:30 -05:00
Winston
b52c66f1be #read_entry in ActiveSupport::Cache::FileStore should log details of the exception when an exception is thrown. 2012-02-22 19:19:05 +08:00
James Smith
c33334fc92 Change FILENAME_MAX_SIZE in FileStore to 228.
In order that temp filenames generated from it will fit in 255 chars. See https://github.com/rails/rails/issues/4907
2012-02-06 17:03:26 +00:00
David Heinemeier Hansson
83dbef6074 Revert "Fix expanding cache key for single element arrays"
This reverts commit abe915f23777efe10f17d611bf5718ca855a0704.

This broke all existing keys and it's wrong anyway. The array is just there as a convenience option for building the string. It's intentional that [ "stuff"] and "stuff" generates the same key.
2012-01-27 20:44:08 +01:00
Marcos Tapajos
e5425c8f68 Cache (FileStore) clear should keep .gitkeep 2012-01-13 13:28:16 -02:00
Karunakar (Ruby)
0023643522 Moved all the logger methods to active support logger
minor
2012-01-06 00:38:46 +05:30
Sergey Nartimov
1e9e88fcd3 remove checks for encodings availability 2011-12-25 14:34:58 +03:00
José Valim
4f35d5a18b Merge pull request #4007 from exviva/expand_cache_key_for_one_element_array
Fix expanding cache key for single element arrays
2011-12-16 14:40:09 -08:00
Olek Janiszewski
abe915f237 Fix expanding cache key for single element arrays
In short:
expand_cache_key(element) should not equal expand_cache_key([element])

This way a fragment cache key for an index page with only a single
element in the collection is different than a fragment cache for a
typical show page for that element.
2011-12-16 17:58:25 +01:00
Brian Durand
04d5eae4e8 Add ActiveSupport::Cache::NullStore to expose caching interface without actually caching for development and test environments. 2011-12-12 13:40:29 -06:00
José Valim
3ee0116c94 Optimize cache expansion by skipping rails cache id in nested keys. 2011-11-23 18:22:09 +00:00
Olek Janiszewski
a650dd05f8 Fix #3737 AS::expand_cache_key generates wrong key in certain situations (part 2)
`nil` and `false` both expand to `""` (empty string), while `true` expands to
`"true"`; `false` should expand to `"false"`
2011-11-23 18:11:38 +01:00
Olek Janiszewski
d8e6dc9cf1 Fix #3737 AS::expand_cache_key generates wrong key in certain situations
`cache_key` method is never called when the argument is a 1-element array
with something that responds to `cache_key`
2011-11-23 18:06:16 +01:00
Xavier Noria
8f57bf207f tests predicates according to the boolean interpretation of their return value, not expecting specifically true or false
Respecting Genuine assert_equal false Edition
2011-11-21 14:22:16 -08:00
Xavier Noria
f312e2142b Revert "tests predicates according to the boolean interpretation of their return value, not expecting specifically true or false"
Reason: there were some genuine tests for false when
reading values, going to revise those ones.

This reverts commit a539a5e3f3be68f027d3dfe43f88dc9f0642c743.
2011-11-21 14:14:11 -08:00
Xavier Noria
a539a5e3f3 tests predicates according to the boolean interpretation of their return value, not expecting specifically true or false 2011-11-21 14:11:40 -08:00
Xavier Noria
f3554777b2 cache entry: options[:compressed] is a regular flag, no need for !! 2011-11-21 14:01:53 -08:00
Philippe Huibonhoa
119a484e80 Improved testing so that it tests the real functionality and not the private method. 2011-10-02 01:39:52 -07:00
Philippe Huibonhoa
0baa8f8604 Added fix so that file store does not raise an exception when cache dir does not exist yet. This can happen if a delete_matched is called before anything is saved in the cache. 2011-09-29 18:59:40 -07:00
Philippe Huibonhoa
a0352a425f Updated existing test that fails with this fix (8d63678d1406c5518d437709af0fde717c0248d7). Before the fix the test was giving a false positive, because file_store.key_file_path would return an empty filename (i.e. test/tmp_cache/4D0/F4D rather than test/tmp_cache/4D0/F4D/xxxx…).
Even though the fix referenced above divides the filename into directories to prevent it from being too long, it seems that 1000 characters will always raise an error, so reducing the key size to 900).
2011-09-21 21:03:59 -07:00
Philippe Huibonhoa
8d63678d14 Fixed issue in file store where it could create a filename that was too long for the file system. (https://github.com/rails/rails/issues/3072) 2011-09-21 21:00:46 -07:00
Santiago Pastorino
6e701e8735 Merge pull request #2393 from bdurand/fix_cache_read_multi
Fix ArgumentError in ActiveSupport::Cache::CacheStore.read_multi
2011-08-01 10:58:48 -07:00
Brian Durand
fec4c5ad76 Pass options in ActiveSupport::Cache::CacheStore#read_multi through to the delete_entry call. 2011-08-01 12:05:29 -05:00
Brian Durand
a263f37797 Change ActiveSupport::Cache behavior to always return duplicate objects instead of frozen objects. 2011-07-29 17:27:45 -05:00
Gonzalo Rodriguez
49b0f9e395 Fix ActiveSupport::Cache::FileStore#file_path_key does not work if initialized with Pathname
Port from 3-1-stable
2011-07-23 17:57:04 -03:00
José Valim
8f2e32158b Merge pull request #1608 from sishen/sishen
MemcacheStore: deserialize the entry reading from local_cache when using
2011-07-11 04:54:28 -07:00
Sebi Burkhard
9e63f9f2e4 Properly cache value when it is "false" 2011-07-08 18:08:37 +07:00
Dingding Ye
c2aacdf2eb MemcacheStore: deserialize the entry reading from local_cache when using raw 2011-06-10 01:15:37 +08:00
Josh Kalderimis
9cafc28874 Removed deprecated methods and related tests from ActiveSupport 2011-05-25 23:39:34 +02:00
Pan Thomakos
72759f5867 Fixed special character encoding issue with MemCacheStore in Ruby 1.9.2. 2011-03-11 17:57:28 -08:00
Aaron Patterson
5968d7a658 do not test explicit equality of predicate methods, they should be allowed to return truthy or falsey objects 2011-03-07 09:36:07 -08:00
Santiago Pastorino
4e0477c9b7 Test cache.key_file_path with separators ht. Jim Wilson [#5611] 2010-11-07 20:02:14 -02:00
Denis Odorcic
c452d734f2 Fix FileStore cache incorrectly regenerating its key from a pathname when a regexp is used in expire_fragment
[#5850 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-11-07 20:01:51 -02:00
Xavier Noria
fb6b805620 code gardening: we have assert_(nil|blank|present), more concise, with better default failure messages - let's use them 2010-08-17 03:32:11 +02:00
Neeraj Singh
4952a80200 adding test for respond_to cache_key and cleaning up the ENV settings 2010-07-28 21:02:45 +08:00
Neeraj Singh
7d29627be9 test cases for rails_app_version in AS cache.rb 2010-07-28 21:02:45 +08:00
Neeraj Singh
3265af5c8b adding more test cases for expand_cache_key 2010-07-28 21:02:44 +08:00
Santiago Pastorino
e1d4e78b15 Removes unused vars
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-24 01:19:44 +02:00
Santiago Pastorino
fdfebb7782 Make use of assert_equal to test equallity between object assert expects and object and a message of error
[#4611 state:committed]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-16 16:06:28 +02:00
Brian Durand
ee51b51b60 ActiveSupport::Cache refactoring
All Caches

* Add default options to initializer that will be sent to all read, write, fetch, exist?, increment, and decrement
* Add support for the :expires_in option to fetch and write for all caches. Cache entries are stored with the create timestamp and a ttl so that expiration can be handled independently of the implementation.
* Add support for a :namespace option. This can be used to set a global prefix for cache entries.
* Deprecate expand_cache_key on ActiveSupport::Cache and move it to ActionController::Caching and ActionDispatch::Http::Cache since the logic in the method used some Rails specific environment variables and was only used by ActionPack classes. Not very DRY but there didn't seem to be a good shared spot and ActiveSupport really shouldn't be Rails specific.
* Add support for :race_condition_ttl to fetch. This setting can prevent race conditions on fetch calls where several processes try to regenerate a recently expired entry at once.
* Add support for :compress option to fetch and write which will compress any data over a configurable threshold.
* Nil values can now be stored in the cache and are distinct from cache misses for fetch.
* Easier API to create new implementations. Just need to implement the methods read_entry, write_entry, and delete_entry instead of overwriting existing methods.
* Since all cache implementations support storing objects, update the docs to state that ActiveCache::Cache::Store implementations should store objects. Keys, however, must be strings since some implementations require that.
* Increase test coverage.
* Document methods which are provided as convenience but which may not be universally available.

MemoryStore

* MemoryStore can now safely be used as the cache for single server sites.
* Make thread safe so that the default cache implementation used by Rails is thread safe. The overhead is minimal and it is still the fastest store available.
* Provide :size initialization option indicating the maximum size of the cache in memory (defaults to 32Mb).
* Add prune logic that removes the least recently used cache entries to keep the cache size from exceeding the max.
* Deprecated SynchronizedMemoryStore since it isn't needed anymore.

FileStore

* Escape key values so they will work as file names on all file systems, be consistent, and case sensitive
* Use a hash algorithm to segment the cache into sub directories so that a large cache doesn't exceed file system limits.
* FileStore can be slow so implement the LocalCache strategy to cache reads for the duration of a request.
* Add cleanup method to keep the disk from filling up with expired entries.
* Fix increment and decrement to use file system locks so they are consistent between processes.

MemCacheStore

* Support all keys. Previously keys with spaces in them would fail
* Deprecate CompressedMemCacheStore since it isn't needed anymore (use :compress => true)

[#4452 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-04-27 11:13:37 -07:00
Jeremy Kemper
03aa7877f7 MemoryStore#read_multi(*keys) for dev-mode compatibility with memcache store 2010-04-19 00:19:10 -07:00
Vladimir Andrijevik
edaf92f5ab Drop expires argument from call to @data in MemCacheStore so it works with memcache-client and memcached gems, as advertised [#3672 state:resolved]
Signed-off-by: wycats <wycats@gmail.com>
2010-03-28 13:57:14 -07:00