Uploaded image for project: 'PHP ORMs'
  1. PHP ORMs
  2. PHPORM-176

Add setting to customize the MongoDB database used for cache and lock

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • PHP Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Suggestion by jmikola@mongodb.com https://github.com/mongodb/laravel-mongodb/pull/2909#discussion_r1579741403

      Add an option to the cache configuration to use a database distinct from the database configured in database.php

      Or parse the collection parameter to detect if there is a namespace.

       

      Currently, it's already possible to use a distinct database for the cache, but this requires using a distinct connection.

       

      // config/database.php
      return [
          'default' => 'mongodb',
          'connections' => [
              'mongodb' => [
              'driver' => 'mongodb',
              'dsn' => env('MONGODB_URI'),
              'database' => 'application',
          ],
          'mongodb-cache' => [
              'driver' => 'mongodb',
              'dsn' => env('MONGODB_URI'),
              'database' => 'cache',
          ],
      
      ]; 

       

       

      // config/cache.php
      return [
          'default' => 'mongodb',
          'stores' => [
              'mongodb' => [
                  'driver' => 'mongodb',
                  'connection' => 'mongodb-cache',
              ],
          ],
      ];

       

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            jerome.tamarelle@mongodb.com Jérôme Tamarelle
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: