Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

44 rindas
1.1KB

  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\mutex;
  8. use Yii;
  9. use yii\db\Connection;
  10. use yii\base\InvalidConfigException;
  11. use yii\di\Instance;
  12. /**
  13. * DbMutex is the base class for classes, which relies on database while implementing mutex "lock" mechanism.
  14. *
  15. * @see Mutex
  16. *
  17. * @author resurtm <resurtm@gmail.com>
  18. * @since 2.0
  19. */
  20. abstract class DbMutex extends Mutex
  21. {
  22. /**
  23. * @var Connection|array|string the DB connection object or the application component ID of the DB connection.
  24. * After the Mutex object is created, if you want to change this property, you should only assign
  25. * it with a DB connection object.
  26. * Starting from version 2.0.2, this can also be a configuration array for creating the object.
  27. */
  28. public $db = 'db';
  29. /**
  30. * Initializes generic database table based mutex implementation.
  31. * @throws InvalidConfigException if [[db]] is invalid.
  32. */
  33. public function init()
  34. {
  35. parent::init();
  36. $this->db = Instance::ensure($this->db, Connection::className());
  37. }
  38. }