SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/Helpers/Rdb.php

  1. <?php
  2. /*
  3.  * Copyright (C) 2020 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  */
  13. namespace Sprout\Helpers;
  14.  
  15. use karmabunny\rdb\Rdb as RealRdb;
  16. use karmabunny\rdb\StaticRdb;
  17. use Kohana;
  18.  
  19. /**
  20.  * Redis wrapper + utilities.
  21.  */
  22. class Rdb extends StaticRdb
  23. {
  24.  
  25. public static function getInstance(): RealRdb
  26. {
  27. static $rdb;
  28. if (!$rdb) {
  29. $config = Kohana::config('redis.default');
  30. $rdb = RealRdb::create($config);
  31. }
  32. return $rdb;
  33. }
  34. }
  35.