redis.lock.inc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * @file
  4. * Drupal core lock.inc replacement.
  5. *
  6. * Do not use this file directly, it will be included by the backend specific
  7. * implementation when added to settings.php file.
  8. *
  9. * See README.txt file for details.
  10. */
  11. // Include our own autoloader to ensure classes to be there.
  12. // We cannot rely on core in case of early bootstrap phases.
  13. require_once dirname(__FILE__) . '/redis.autoload.inc';
  14. /**
  15. * Foo function, keeping it for API consistency (Drupal 7).
  16. */
  17. function lock_initialize() {}
  18. /**
  19. * Foo function, keeping it for API consistency (Drupal 6).
  20. */
  21. function lock_init() {}
  22. /**
  23. * Foo function, keeping it for API consistency.
  24. * Some insane people may actually use it.
  25. */
  26. function _lock_id() {
  27. return Redis_Lock::getBackend()->getLockId();
  28. }
  29. function lock_acquire($name, $timeout = 30.0) {
  30. return Redis_Lock::getBackend()->lockAcquire($name, $timeout);
  31. }
  32. function lock_may_be_available($name) {
  33. return Redis_Lock::getBackend()->lockMayBeAvailable($name);
  34. }
  35. function lock_wait($name, $delay = 30) {
  36. return Redis_Lock::getBackend()->lockWait($name, $delay);
  37. }
  38. function lock_release($name) {
  39. return Redis_Lock::getBackend()->lockRelease($name);
  40. }
  41. function lock_release_all($lock_id = NULL) {
  42. return Redis_Lock::getBackend()->lockReleaseAll($lock_id);
  43. }
  44. // Since D6 doesn't have the drupal_register_shutdown_function
  45. // that is called in lib/Redis/Lock/Backend/Default.php define
  46. // the wrapper here.
  47. if (!function_exists('drupal_register_shutdown_function')) {
  48. function drupal_register_shutdown_function(){
  49. $args = func_get_args();
  50. call_user_func_array('register_shutdown_function', $args);
  51. }
  52. }