##// END OF EJS Templates
caches: use single default cache dir for all backends....
marcink -
r3008:ab171c02 default
parent child Browse files
Show More
@@ -436,13 +436,23 b' def _sanitize_vcs_settings(settings):'
436
436
437
437
438 def _sanitize_cache_settings(settings):
438 def _sanitize_cache_settings(settings):
439 _string_setting(settings, 'cache_dir',
439 default_cache_dir = os.path.join(tempfile.gettempdir(), 'rc_cache')
440 os.path.join(tempfile.gettempdir(), 'rc_cache'))
440
441 # save default, cache dir, and use it for all backends later.
442 default_cache_dir = _string_setting(
443 settings,
444 'cache_dir',
445 default_cache_dir, lower=False, default_when_empty=True)
446
447 # ensure we have our dir created
448 if not os.path.isdir(default_cache_dir):
449 os.makedirs(default_cache_dir, mode=0755)
450
441 # cache_perms
451 # cache_perms
442 _string_setting(
452 _string_setting(
443 settings,
453 settings,
444 'rc_cache.cache_perms.backend',
454 'rc_cache.cache_perms.backend',
445 'dogpile.cache.rc.file_namespace')
455 'dogpile.cache.rc.file_namespace', lower=False)
446 _int_setting(
456 _int_setting(
447 settings,
457 settings,
448 'rc_cache.cache_perms.expiration_time',
458 'rc_cache.cache_perms.expiration_time',
@@ -450,13 +460,13 b' def _sanitize_cache_settings(settings):'
450 _string_setting(
460 _string_setting(
451 settings,
461 settings,
452 'rc_cache.cache_perms.arguments.filename',
462 'rc_cache.cache_perms.arguments.filename',
453 os.path.join(tempfile.gettempdir(), 'rc_cache_1'))
463 os.path.join(default_cache_dir, 'rc_cache_1'), lower=False)
454
464
455 # cache_repo
465 # cache_repo
456 _string_setting(
466 _string_setting(
457 settings,
467 settings,
458 'rc_cache.cache_repo.backend',
468 'rc_cache.cache_repo.backend',
459 'dogpile.cache.rc.file_namespace')
469 'dogpile.cache.rc.file_namespace', lower=False)
460 _int_setting(
470 _int_setting(
461 settings,
471 settings,
462 'rc_cache.cache_repo.expiration_time',
472 'rc_cache.cache_repo.expiration_time',
@@ -464,13 +474,13 b' def _sanitize_cache_settings(settings):'
464 _string_setting(
474 _string_setting(
465 settings,
475 settings,
466 'rc_cache.cache_repo.arguments.filename',
476 'rc_cache.cache_repo.arguments.filename',
467 os.path.join(tempfile.gettempdir(), 'rc_cache_2'))
477 os.path.join(default_cache_dir, 'rc_cache_2'), lower=False)
468
478
469 # cache_license
479 # cache_license
470 _string_setting(
480 _string_setting(
471 settings,
481 settings,
472 'rc_cache.cache_license.backend',
482 'rc_cache.cache_license.backend',
473 'dogpile.cache.rc.file_namespace')
483 'dogpile.cache.rc.file_namespace', lower=False)
474 _int_setting(
484 _int_setting(
475 settings,
485 settings,
476 'rc_cache.cache_license.expiration_time',
486 'rc_cache.cache_license.expiration_time',
@@ -478,13 +488,13 b' def _sanitize_cache_settings(settings):'
478 _string_setting(
488 _string_setting(
479 settings,
489 settings,
480 'rc_cache.cache_license.arguments.filename',
490 'rc_cache.cache_license.arguments.filename',
481 os.path.join(tempfile.gettempdir(), 'rc_cache_3'))
491 os.path.join(default_cache_dir, 'rc_cache_3'), lower=False)
482
492
483 # cache_repo_longterm memory, 96H
493 # cache_repo_longterm memory, 96H
484 _string_setting(
494 _string_setting(
485 settings,
495 settings,
486 'rc_cache.cache_repo_longterm.backend',
496 'rc_cache.cache_repo_longterm.backend',
487 'dogpile.cache.rc.memory_lru')
497 'dogpile.cache.rc.memory_lru', lower=False)
488 _int_setting(
498 _int_setting(
489 settings,
499 settings,
490 'rc_cache.cache_repo_longterm.expiration_time',
500 'rc_cache.cache_repo_longterm.expiration_time',
@@ -498,7 +508,7 b' def _sanitize_cache_settings(settings):'
498 _string_setting(
508 _string_setting(
499 settings,
509 settings,
500 'rc_cache.sql_cache_short.backend',
510 'rc_cache.sql_cache_short.backend',
501 'dogpile.cache.rc.memory_lru')
511 'dogpile.cache.rc.memory_lru', lower=False)
502 _int_setting(
512 _int_setting(
503 settings,
513 settings,
504 'rc_cache.sql_cache_short.expiration_time',
514 'rc_cache.sql_cache_short.expiration_time',
@@ -511,6 +521,7 b' def _sanitize_cache_settings(settings):'
511
521
512 def _int_setting(settings, name, default):
522 def _int_setting(settings, name, default):
513 settings[name] = int(settings.get(name, default))
523 settings[name] = int(settings.get(name, default))
524 return settings[name]
514
525
515
526
516 def _bool_setting(settings, name, default):
527 def _bool_setting(settings, name, default):
@@ -518,6 +529,7 b' def _bool_setting(settings, name, defaul'
518 if isinstance(input_val, unicode):
529 if isinstance(input_val, unicode):
519 input_val = input_val.encode('utf8')
530 input_val = input_val.encode('utf8')
520 settings[name] = asbool(input_val)
531 settings[name] = asbool(input_val)
532 return settings[name]
521
533
522
534
523 def _list_setting(settings, name, default):
535 def _list_setting(settings, name, default):
@@ -530,13 +542,20 b' def _list_setting(settings, name, defaul'
530 else:
542 else:
531 # Otherwise we assume it uses pyramids space/newline separation.
543 # Otherwise we assume it uses pyramids space/newline separation.
532 settings[name] = aslist(raw_value)
544 settings[name] = aslist(raw_value)
545 return settings[name]
533
546
534
547
535 def _string_setting(settings, name, default, lower=True):
548 def _string_setting(settings, name, default, lower=True, default_when_empty=False):
536 value = settings.get(name, default)
549 value = settings.get(name, default)
550
551 if default_when_empty and not value:
552 # use default value when value is empty
553 value = default
554
537 if lower:
555 if lower:
538 value = value.lower()
556 value = value.lower()
539 settings[name] = value
557 settings[name] = value
558 return settings[name]
540
559
541
560
542 def _substitute_values(mapping, substitutions):
561 def _substitute_values(mapping, substitutions):
General Comments 0
You need to be logged in to leave comments. Login now