153 Commits

Author SHA1 Message Date
Leon Stringer
36b6444420 MDL-64719 cache: Implement purge_current_user() in \cache
\cache::make() may return a cache_disabled subclass but callers, specifically
user/lib.php:user_create_user(), invoke \cache::purge_current_user() which was
only implemented by the cache_session subclass.  Added empty
\cache::purge_current_user() which subclasses can implement, i.e.
cache_session, or not, i.e. cache_disabled.
2019-04-01 15:29:39 +01:00
David Mudrák
0ea0dfde6d MDL-64452 cache: Always use the current session id in the key prefix
The current logic in the cache_session::check_tracked_user() is not
right. We must always set the current session id. A typical use case is
when the cache instance is instantiated for a not logged in user. We
can't let the sessionid property null in that case as it forms an
important part of the parsed key.

Similarly, even if we have the same user currently loaded, we must still
set the sessionid to make sure the data will be associated with the
current PHP session. Same user (including visitors or guest users) can
access the site from different browsers and each must end up with its
own key prefix.
2019-02-15 09:36:43 +01:00
Andrew Nicols
c96cd71102 MDL-63924 privacy: Add shared user providers to subsytsems 2018-11-08 21:26:18 +08:00
Andrew Nicols
0a197875df MDL-63101 cache: Improve accuracy of cache event invalidation 2018-08-27 14:43:42 +08:00
Andrew Nicols
26bb44e5f4 MDL-61898 core_cache: Implement Privacy API 2018-04-30 14:07:27 +08:00
sam marshall
4998d3a5be MDL-59427 MUC: cache_helper::purge_all should reset adhoc caches 2017-06-30 11:15:30 +01:00
Skylar Kelty
32ec2da151 MDL-58658 caching: Fix static acceleration for empty arrays 2017-04-20 09:49:09 +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
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
Andrew Nicols
70aa00de87 MDL-56748 cache: Removes cache definition instances in purge_store
Previously a purge_store was only purging caches but it was leaving a
reference to the store instance for the cache definition.

As a result, the cache was never cleared away correctly and, in cases
where the cache store makes a TCP connection to a backend system, the
number of open sockets was increasing for each store instance.

After a complete purge, as found in the unit test reset, the cache
definitions should be both purged and removed.

This change should also lead to a drop in memory consumption for unit
tests as there will no longer be references to unused definition stores.
2016-11-04 13:26:46 +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
Russell Smith
f9599c77cc MDL-56273 cache: Ensure requirements are met for cache stores.
Ensure that the cache store requirements are met prior to attempting
to instantiate a class.  Many of the constructors create connections
to external services requiring the installation and availability of
classes that are specified in are_requirements_met().  If they are
not checked properly you end up with PHP Fatal errors rather than
falling back to a different store that is capabable without the
the extra classes loaded.
2016-10-31 16:04:51 +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
Andrew Nicols
9c792b9861 Merge branch 'MDL-55922' of https://github.com/mr-russ/moodle 2016-10-25 15:11:43 +08:00
Rajesh Taneja
ca9a79dae3
MDL-56348 cache: Removed second parameter
There is no second parameter in the api
and identifier should be set by set_identifiers
2016-10-11 12:50:10 +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
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
Mark Nelson
e1f53120dd MDL-54984 core_cache: corrected exception message 2016-07-27 11:42:47 +08:00
Jun Pataleta
d6806d8eaf MDL-54984 cache: Added todo tags to items for 3.3 deprecations 2016-07-26 00:46:46 +08:00
Jun Pataleta
329642b9c5 MDL-54984 cache: 3.2 final deprecations 2016-07-26 00:46:37 +08:00
Michael Aherne
f0ed09852e MDL-53256 cache: Prevent overwriting of cache config with invalid data 2016-04-01 08:52:21 +01:00
Andrew Nicols
ae3c6ee42d MDL-52346 caching: Coding style fixes 2016-02-29 14:14:01 +08:00
Andrew Nicols
8bd28ed696 Merge branch 'MDL-52346' of git://github.com/mr-russ/moodle 2016-02-29 14:12:03 +08:00
Andrew Nicols
d96a4e2a59 MDL-53206 caching: Remove accidental use of fullresult variable 2016-02-29 13:20:29 +08:00
Russell Smith
fdff8077e0 MDL-53208 caching: Update serialization rules for performance.
- We only now serialize when required, eg when the store doesn't do it.
- static acceleration now serializes on set to reduce overhead on load.
- null now works in static acceleration as we use an array for storage metadata
- static acceleration delete uses isset rather than an array_search.
2016-02-28 17:01:51 +11:00
Russell Smith
76349f871e MDL-53208 caching: Remove TTL wrapper on static acceleration.
TTL is only updated between script runs.  If it's valid
when it's added to static acceleration, it will be valid
for the entire script run.
2016-02-28 17:01:50 +11: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
80788d03e1 MDL-53208 caching: Update serialization rules for performance.
- We only now serialize when required, eg when the store doesn't do it.
- static acceleration now serializes on set to reduce overhead on load.
- null now works in static acceleration as we use an array for storage metadata
- static acceleration delete uses isset rather than an array_search.
2016-02-28 17:01:50 +11:00
Russell Smith
b2159f2d3f MDL-53208 caching: Enable dereferencing as a feature.
If the cache does all the dereferencing when it stores and loads
the objects, then the cache loaders don't need to do that work.
This is true of all caches that use something other than PHP's memory
to store their results.
2016-02-28 17:01:49 +11:00
Russell Smith
5007975d1e MDL-53206 caching: Ensure get_many and set_many dereference objects. 2016-02-28 17:01:49 +11:00
Russell Smith
4350192a8d MDL-52346 caching: Allow localstorage as a cache option.
We display a notification on screen during configuration telling
the administrator if it's safe to map this store to a local storage
cache or not.
2016-02-26 10:58:20 +11:00
Matt Petro
2351ed55e8 MDL-51482 caching: Fix unnecessary updates to lastinvalidation time 2015-10-08 11:48:17 -04:00
Frederic Massart
e75115810c MDL-50949 cache: Performance debug keeps track of hits/misses/sets 2015-07-29 12:56:10 +08:00
Marina Glancy
2d1164800c MDL-49572 cache: correctly purge cache on event 2015-05-20 14:07:58 +08:00
Sam Hemelryk
7fa57e0341 MDL-39459 cache: mode included in stats output
The cache store mode is now included in the performance stats
printed at the bottom of the page.
It is represented as either [a] [s] or [r] and a title is used
to actually state the mode.
2015-02-04 09:35:21 +13:00
Eloy Lafuente (stronk7)
c0d8831ae7 MDL-45699 behat: Don't use behat/lib.php functions in core.
behat/lib.php script should not be usually included, neither any of its functions
used within mooodle code at all. It's for exclusive use of behat and
moodle setup.php. For places requiring a different/special behavior
needing to check if are being run  as part of behat tests, use:
    if (defined('BEHAT_SITE_RUNNING')) { ...
2014-12-23 12:29:44 +01: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
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
83bee88119 MDL-47832 cache: removed data source aggregate functionality
Cache data source aggregate functionality was found to be broken
and unused, because of this the decision was made to remove it
rather than fix it.
As it was broken we did not follow typical deprecation methods and
instead the code was removed outright with only structure
remaining and left deprecated.
2014-11-20 11:02:56 +13:00
Sam Hemelryk
ed2de2ecc7 MDL-45724 cache: fixed warning structure bug 2014-07-23 15:24:59 +12:00
Sam Hemelryk
915140c9b5 MDL-45724 cache: added cache API warnings to the admin notifications page 2014-07-21 09:48:33 +12:00
Sam Hemelryk
727c21733e MDL-45724 cache: admin screen now shows store warnings
Implemented a means by which cache store instance can communicate
warnings due to things such as conflicting configurations etc.
2014-07-18 08:29:41 +12: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
Damyon Wiese
4e8a350c35 Merge branch 'MDL-45618' of git://github.com/timhunt/moodle 2014-05-20 14:59:48 +08:00