The MongoDB Cache store.
More...
|
MongoDB Collection | $collection |
| The Collection object.
|
|
MongoDB Client | $connection = false |
| The Connection object.
|
|
MongoDB Database | $database |
| The Database Object.
|
|
string | $databasename = 'mcache' |
| The name of the database to use.
|
|
string | $definitionhash = null |
| The definition has which is used in the construction of the collection.
|
|
bool | $extendedmode = false |
| If set to true then multiple identifiers will be requested and used.
|
|
bool | $isready = false |
| Set to true once this store is ready to be initialised and used.
|
|
string | $name |
| The name of the store.
|
|
array | $options = array() |
| The database connection options.
|
|
string | $server = 'mongodb://127.0.0.1:27017' |
| The server connection string. More...
|
|
bool int | $usesafe = true |
| Determines if and what safe setting is to be used.
|
|
The MongoDB Cache store.
This cache store uses the MongoDB Native Driver and the MongoDB PHP Library. For installation instructions have a look at the following two links:
- Copyright
- 2012 Sam Hemelryk
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ __construct()
cachestore_mongodb::__construct |
( |
|
$name, |
|
|
array |
$configuration = array() |
|
) |
| |
Constructs a new instance of the Mongo store.
Noting that this function is not an initialisation. It is used to prepare the store for use. The store will be initialised when required and will be provided with a cache_definition at that time.
- Parameters
-
string | $name | |
array | $configuration | |
Reimplemented from cache_store.
◆ are_requirements_met()
static cachestore_mongodb::are_requirements_met |
( |
| ) |
|
|
static |
Returns true if the requirements of this store have been met.
- Return values
-
Implements cache_store_interface.
◆ can_add_instance()
static cache_store::can_add_instance |
( |
| ) |
|
|
staticinherited |
◆ cleanup()
◆ config_get_configuration_array()
static cachestore_mongodb::config_get_configuration_array |
( |
|
$data | ) |
|
|
static |
Takes the object from the add instance store and creates a configuration array that can be used to initialise an instance.
- Parameters
-
- Return values
-
Implements cache_is_configurable.
◆ config_set_edit_form_data()
static cachestore_mongodb::config_set_edit_form_data |
( |
moodleform |
$editform, |
|
|
array |
$config |
|
) |
| |
|
static |
Allows the cache store to set its data against the edit form before it is shown to the user.
- Parameters
-
moodleform | $editform | |
array | $config | |
Implements cache_is_configurable.
◆ create_clone()
cache_store::create_clone |
( |
array |
$details = array() | ) |
|
|
inherited |
Creates a clone of this store instance ready to be initialised.
This method is used so that a cache store needs only be constructed once. Future requests for an instance of the store will be given a cloned instance.
If you are writing a cache store that isn't compatible with the clone operation you can override this method to handle any situations you want before cloning.
- Parameters
-
array | $details | An array containing the details of the store from the cache config. |
- Return values
-
◆ delete()
cachestore_mongodb::delete |
( |
|
$key | ) |
|
Deletes an item from the cache store.
- Parameters
-
string | $key | The key to delete. |
- Return values
-
bool | Returns true if the operation was a success, false otherwise. |
Reimplemented from cache_store.
◆ delete_many()
cachestore_mongodb::delete_many |
( |
array |
$keys | ) |
|
Deletes several keys from the cache in a single action.
- Parameters
-
array | $keys | The keys to delete |
- Return values
-
int | The number of items successfully deleted. |
Reimplemented from cache_store.
◆ get()
cachestore_mongodb::get |
( |
|
$key | ) |
|
Retrieves an item from the cache store given its key.
- Parameters
-
string | $key | The key to retrieve |
- Return values
-
mixed | The data that was associated with the key, or false if the key did not exist. |
Reimplemented from cache_store.
◆ get_many()
cachestore_mongodb::get_many |
( |
|
$keys | ) |
|
Retrieves several items from the cache store in a single transaction.
If not all of the items are available in the cache then the data value for those that are missing will be set to false.
- Parameters
-
array | $keys | The array of keys to retrieve |
- Return values
-
array | An array of items from the cache. |
Reimplemented from cache_store.
◆ get_supported_features()
static cachestore_mongodb::get_supported_features |
( |
array |
$configuration = array() | ) |
|
|
static |
◆ get_supported_modes()
static cachestore_mongodb::get_supported_modes |
( |
array |
$configuration = array() | ) |
|
|
static |
Returns an int describing the supported modes.
- Parameters
-
- Return values
-
Implements cache_store_interface.
◆ get_warnings()
cache_store::get_warnings |
( |
| ) |
|
|
inherited |
Can be overridden to return any warnings this store instance should make to the admin.
This should be used to notify things like configuration conflicts etc. The warnings returned here will be displayed on the cache configuration screen.
- Return values
-
string[] | An array of warning strings from the store instance. |
Reimplemented in cachestore_memcached.
◆ initialise()
Initialises the store instance for use.
Once this has been done the cache is all set to be used.
- Parameters
-
- Exceptions
-
Reimplemented from cache_store.
◆ initialise_test_instance()
static cachestore_mongodb::initialise_test_instance |
( |
cache_definition |
$definition | ) |
|
|
static |
Generates an instance of the cache store that can be used for testing.
- Parameters
-
- Return values
-
Implements cache_store_interface.
◆ instance_created()
cache_store::instance_created |
( |
| ) |
|
|
inherited |
Performs any necessary operation when the store instance has been created.
- Since
- Moodle 2.5
Reimplemented in cachestore_file.
◆ is_initialised()
cachestore_mongodb::is_initialised |
( |
| ) |
|
Returns true if this store instance has been initialised.
- Return values
-
Reimplemented from cache_store.
◆ is_ready()
cachestore_mongodb::is_ready |
( |
| ) |
|
Returns true if this store instance is ready to use.
- Return values
-
Reimplemented from cache_store.
◆ is_searchable()
cache_store::is_searchable |
( |
| ) |
|
|
inherited |
Returns true if the store instance is searchable.
- Return values
-
◆ is_supported_mode()
static cachestore_mongodb::is_supported_mode |
( |
|
$mode | ) |
|
|
static |
Returns true if the given mode is supported by this store.
- Parameters
-
- Return values
-
Implements cache_store_interface.
◆ my_name()
cachestore_mongodb::my_name |
( |
| ) |
|
Returns the name of this instance.
- Return values
-
Reimplemented from cache_store.
◆ purge()
cachestore_mongodb::purge |
( |
| ) |
|
Purges the cache deleting all items within it.
- Return values
-
boolean | True on success. False otherwise. |
Reimplemented from cache_store.
◆ ready_to_be_used_for_testing()
static cachestore_mongodb::ready_to_be_used_for_testing |
( |
| ) |
|
|
static |
Returns true if this cache store instance is both suitable for testing, and ready for testing.
Cache stores that support being used as the default store for unit and acceptance testing should override this function and return true if there requirements have been met.
- Return values
-
Reimplemented from cache_store.
◆ set()
cachestore_mongodb::set |
( |
|
$key, |
|
|
|
$data |
|
) |
| |
Sets an item in the cache given its key and data value.
- Parameters
-
string | $key | The key to use. |
mixed | $data | The data to set. |
- Return values
-
bool | True if the operation was a success false otherwise. |
Reimplemented from cache_store.
◆ set_many()
cachestore_mongodb::set_many |
( |
array |
$keyvaluearray | ) |
|
Sets many items in the cache in a single transaction.
- Parameters
-
array | $keyvaluearray | An array of key value pairs. Each item in the array will be an associative array with two keys, 'key' and 'value'. |
- Return values
-
int | The number of items successfully set. It is up to the developer to check this matches the number of items sent ... if they care that is. |
Reimplemented from cache_store.
◆ supports_data_guarantee()
cache_store::supports_data_guarantee |
( |
| ) |
|
|
inherited |
Returns true if the store instance guarantees data.
- Return values
-
◆ supports_dereferencing_objects()
cache_store::supports_dereferencing_objects |
( |
| ) |
|
|
inherited |
Returns true if the store automatically dereferences objects.
- Return values
-
◆ supports_multiple_identifiers()
cachestore_mongodb::supports_multiple_identifiers |
( |
| ) |
|
Returns true if this store is making use of multiple identifiers.
- Return values
-
Reimplemented from cache_store.
◆ supports_native_ttl()
cache_store::supports_native_ttl |
( |
| ) |
|
|
inherited |
Returns true if the store instance supports native ttl.
- Return values
-
◆ unit_test_configuration()
static cachestore_mongodb::unit_test_configuration |
( |
| ) |
|
|
static |
Generates an instance of the cache store that can be used for testing.
- Parameters
-
- Return values
-
Implements cache_store_interface.
◆ $server
string cachestore_mongodb::$server = 'mongodb://127.0.0.1:27017' |
|
protected |
The server connection string.
Comma separated values.
◆ DEREFERENCES_OBJECTS
const cache_store::DEREFERENCES_OBJECTS = 16 |
|
inherited |
The cache store dereferences objects.
When set, loaders will assume that all data coming from this store has already had all references resolved. So even for complex object structures it will not try to remove references again.
◆ MODE_APPLICATION
const cache_store::MODE_APPLICATION = 1 |
|
inherited |
Application caches.
These are shared caches.
◆ MODE_REQUEST
const cache_store::MODE_REQUEST = 4 |
|
inherited |
Request caches.
Static caches really.
◆ MODE_SESSION
const cache_store::MODE_SESSION = 2 |
|
inherited |
Session caches.
Just access to the PHP session.
The documentation for this class was generated from the following file: