82 Commits

Author SHA1 Message Date
Skylar Kelty
761ac5a0aa
MDL-58658 caching: Add static acceleration unit test for empty arrays 2017-05-11 10:56:04 +01:00
Eloy Lafuente (stronk7)
4d505af519 Merge branch 'MDL-55267-master-deprecation' of https://github.com/marcusgreen/moodle 2017-03-21 10:18:56 +01:00
Rajesh Taneja
dba39da081 MDL-58169 phpunit: Clear opcode cache before checking file
In unit test, we write cache file often and
opcache might fail to detect changes. It will
be nice to invalidate opcode cache to ensure
we have the correct file_exists status
2017-03-14 13:30:24 +08:00
Marcus Green
f2894f322d MDL-55267 cache: Remove deprecated field datasourceaggregate 2017-03-13 16:31:45 +00:00
Russell Smith
f3789f2fb3 MDL-45584 cache: Make identifiers part of the cache creation.
It is now safe to cache a reference to a cache and expect consistent results.

Changing identifiers altered cache results where a reference was
held to the cache. Identifiers have been set to be cached with
identifiers included so the caches are separate.

As a consequence of this it was identified that invalidation events
and identifiers don't easily work together as an event can't determine
which identifiers should be used for cache invalidation.  So invalidation
events have been made incompatible with identifiers being set.  No core
code used this combination as it's not possible to understand any expected
behaviour.

Event invalidation for application and session caches was centralised to the same
location.  The only difference was the name of the lastinvalidation variable. This
improves support and consistency of invalidation code.
2017-03-02 11:06:17 +08:00
Jonathan Champ
d3a6b91aec MDL-57427 cache: Use perfdebug only when enabled 2017-01-09 10:18:13 -05:00
Rajesh Taneja
96813571b1
MDL-57147 phpunit: Check if time is greater than or equal to
Some windows only have 1/100 microtime resolution
so a lot of times it does not advance enough.
2016-11-28 09:40:21 +08:00
Andrew Nicols
8fa816e0b0 Merge branch 'wip-mdl-56273' of https://github.com/rajeshtaneja/moodle 2016-11-02 14:30:08 +08:00
Rajesh Taneja
4a910b9aa6
MDL-56273 cache: Fixed initialise call
After store is created, it should be checked if
it's ready before calling initialise
2016-11-02 14:26:50 +08:00
Andrew Nicols
c6ae02c184 Merge branch 'MDL-48468' of https://github.com/mr-russ/moodle 2016-11-02 10:13:42 +08:00
Russell Smith
a330e83ade MDL-56273 cache: Use is_ready() to determine if cache is really ready. 2016-10-31 19:44:05 +11:00
Russell Smith
a169739d5d MDL-56273 cache: Use cache initialise always.
purge_all() and purge_by_definition() look in the configuration
for which caches are available and then creates them to purge them.
The configuration stores the values used by initialise(), not
initialise_unit_test_instance() and would therefore fail to purge
all caches if they were not purged by another means.

In the case of filestore, it's purged by unit tests, in the case
of memcache(d), it purges the whole store when a single definition
is requested.

Therefore all configuration was moved into the configuration file
during unit tests and does not have any special override codes in
the unit test infrastructure.
2016-10-30 13:42:43 +11:00
Russell Smith
68b1e13094 MDL-48468 cache: Import Redis cachestore
This code was originally taken from; https://github.com/durana/moodle-cachestore_redis
Special thanks to Mark Nielsen and Adam Durana for their work on this.

Since the original import;
- Mode session support has been added.
- Some cleanup of names has been made.
- Data guarantee and references support was added.
2016-10-30 13:34:43 +11:00
David Monllao
ab9ca549e7 Merge branch 'wip-mdl-56347' of https://github.com/rajeshtaneja/moodle 2016-10-25 15:20:06 +08:00
Russell Smith
ae9e735c77
MDL-56347 caching: Better class variables for notices. 2016-10-21 09:21:11 +08:00
Rajesh Taneja
502b66f53d
MDL-56347 phpunit: Set class for alternative cache store
If alternative cache store is sued, then set the class
and warn user about this.
2016-10-21 09:20:37 +08:00
Russell Smith
ec4b83b92a MDL-55922 cache: Improve static cache performance
Static cache has a very flexible storage capability
and does not need all the checks performed on it.
Enabling dereferencing handling and multiple identifiers
removes a lot of unneeded overhead for request caches that
have many get calls.

The changes were modelled on the static acceleration changes
done in MDL-53208.
2016-09-12 11:58:55 +10:00
David Monllao
4b5e0c542a MDL-55604 cache: Updating comment according to code changes 2016-08-24 09:39:15 +08:00
Russell Smith
7ff43e1acf MDL-55604 cache: Fix identifier and cacheable_object
When a cachable object is store in the static cache from
the backing store, it was incorrect serialised rather than
using the wake function.  This has been resolved and tests added.

During the investigation into cacheable_object, it was discovered
that set_identifiers never removes identifiers when you call it,
so set_identifiers(array('a')) and set_identifiers(array('b')) really
resulted in array('a','b') as the identifiers rather than 'b'.

The fix for this issue depends on the set_identifiers fix and
they have been coupled together as a result.
2016-08-24 11:26:20 +10:00
Jun Pataleta
d6806d8eaf MDL-54984 cache: Added todo tags to items for 3.3 deprecations 2016-07-26 00:46:46 +08:00
Russell Smith
98d580888b MDL-53208 caching: parse_key not required for static cache.
static cache operates on a single cache instance, it can't share
with others and can use the supplied key immediately.
2016-02-28 17:01:50 +11:00
Russell Smith
5007975d1e MDL-53206 caching: Ensure get_many and set_many dereference objects. 2016-02-28 17:01:49 +11:00
Matt Petro
2351ed55e8 MDL-51482 caching: Fix unnecessary updates to lastinvalidation time 2015-10-08 11:48:17 -04:00
Andrew Nicols
6270f4dbdd MDL-50949 cache: Improve cache performance tests 2015-08-10 08:04:03 +08:00
Frederic Massart
47b04bcf7f MDL-50949 cache: Tests for performance debugging of cache usage 2015-07-29 14:38:58 +08:00
David Monllao
b3e6802cf8 MDL-42192 caches: Adding simpledata tests 2015-05-29 17:18:31 +08:00
Eloy Lafuente (stronk7)
093c161d46 Merge branch '45699-29' of git://github.com/samhemelryk/moodle
Conflicts:
	cache/upgrade.txt
2014-12-23 02:01:36 +01:00
Eloy Lafuente (stronk7)
57bd925603 MDL-48568 cache: make tests aware of default application store
When an alternative cache configuration is used, aka:

define('TEST_CACHE_USING_ALT_CACHE_CONFIG_PATH', true);
$CFG->altcacheconfigpath = '/tmp/xxxxx.php';

the get_expected_application_cache_store() method was not able of
retroffiting the default application store being used.

This commit just implements that functionality so, when
executing unit tests using alternative configuration, assertions
looking for that will pass without a problem.
2014-12-23 01:34:35 +01:00
Sam Hemelryk
63b159d0d4 MDL-48568 cache: stores now determine testing
Cache stores are now responsible for deciding if they are suitable
for use as the primary cache store during unit and acceptance tests

Changes are as follows:
* New method: cache_store::ready_to_be_used_for_testing
* Core cache store have been updated to override this method as
  required.
* MongoDB usesafe default changed to true to match actual default
  behaviour.
2014-12-12 09:30:46 +13:00
Sam Hemelryk
427c41ef2d MDL-45699 cache: renamed cache_config_phpunittest
Renamed cache_config_phpunittest to cache_config_testing
2014-12-09 10:51:38 +13:00
Sam Hemelryk
45a8db7f7b MDL-45699 cache: acceptance test improvements
We now use the unit test cache config class when running
acceptance tests so that the same defines are applicable there.
2014-12-09 10:51:34 +13:00
Sam Hemelryk
c1fb8f6d2e MDL-46151 cachestore_memcache: now checks extension version for support 2014-10-14 08:27:45 +13:00
Sam Hemelryk
c9ef35e1f3 MDL-46208 cachestore_mongo: fixed invalid collection name use 2014-07-04 08:11:27 +12:00
Sam Hemelryk
eefb680d8e MDL-45513 cache: implemented defines for unit testing alternative caches 2014-05-30 08:41:07 +12:00
Sam Hemelryk
79a8ea653c MDL-45513 cache: added support to unit tests for alt cache stores 2014-05-30 08:41:07 +12:00
Eric Merrill
e39099ac36 MDL-45603 cache Fix the mappingsonly option to work as advertised. 2014-05-17 23:48:33 -04:00
Sam Hemelryk
7310a6637a MDL-41997 cache: added unit tests for disabled stores 2013-09-30 09:41:03 +13:00
Sam Hemelryk
b51fed38f2 MDL-40903 cache: renamed loader method to reflect static accelerator 2013-09-25 09:05:18 +12:00
Sam Hemelryk
d074fb091d MDL-40903 cache: renamed persistcache to staticacceleration 2013-09-25 09:05:18 +12:00
Marina Glancy
d67a1a8815 MDL-40903 cache: Unittests and small fixes for persistent application cache 2013-09-25 09:04:36 +12:00
Sam Hemelryk
8bc1d659b8 MDL-40903 cache: coding style tidyup pre-integration 2013-09-25 09:04:35 +12:00
Sam Hemelryk
083fa87759 MDL-40903 cache: converted persistent into persistentdata
At the same time all cache instances were made persistent
2013-09-25 09:04:35 +12:00
Sam Hemelryk
85008bedd5 MDL-41106 cache: several fixes for the session cache.
This issue makes several fixes for the session loader and the session store.
 * maxsize argument now works for session caches.
 * fixed performance hole when interation occurs frequently.
 * fixed cache purge bug occuring when multiple caches are defined before being used.
 * improved lastaccess handling.

Big thanks to Marina who contributed the following commits:
 * Always make sure the elements in cache are sorted so we need to remove only elements in the beginning of array
 * Remove expired elements from session store to free memory
 * Minor bug fixes
2013-08-26 09:15:57 +12:00
Petr Škoda
96f81ea385 MDL-39474 introduce $CFG->debugdeveloper and cleanup $CFG init 2013-08-12 13:01:47 +02:00
Petr Škoda
8252b7c291 MDL-40901 standardise core test case class and file names
This finally allows us to type only the class name when executing individual core test cases.
2013-08-04 22:10:31 +02:00
Damyon Wiese
05b659b252 MDL-40727 Cache: Fix file cache store on windows. 2013-07-24 17:04:44 +08:00
Sam Hemelryk
923f1c420c MDL-40700 cache: fixed cache store unit tests 2013-07-22 10:40:45 +12:00
Eloy Lafuente (stronk7)
3f0a8871d3 Merge branch 'MDL-40555-master' of git://github.com/FMCorz/moodle
Conflicts:
	cache/stores/static/lib.php
2013-07-16 09:57:34 +02:00
Sam Hemelryk
4a749e93b4 MDL-40555 cache: implemented unit tests for default search functionality 2013-07-16 08:29:17 +08:00
Russell Smith
ae21341523 MDL-40538 caching: Use isset for performance
isset is much faster than array_key_exists. For caches we need to
ensure as much performance as possible. To all null to continue to
be stored and provide correct results, non ttl also now saves in
$this->store[$key][0].  As isset($this->store[$key]) will return
true in all cases.

time() as found in cache::now() can be slow on some platforms and
we shouldn't bother checking it unless needed. It also stops non-ttl
caches paying the ttl price.

Unit tests were adjusted to ensure null is still handled correctly
when we are only using isset.
2013-07-10 10:15:19 +10:00