Skip to content

Commit

Permalink
FIX: allow the FileSystem driver to configure the key hashing function.
Browse files Browse the repository at this point in the history
  • Loading branch information
pwhelan committed Feb 19, 2013
1 parent 24bbc64 commit f51fbae
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Stash/Driver/FileSystem.php
Expand Up @@ -68,7 +68,8 @@ class FileSystem implements DriverInterface
protected $defaultOptions = array('filePermissions' => 0660, protected $defaultOptions = array('filePermissions' => 0660,
'dirPermissions' => 0770, 'dirPermissions' => 0770,
'dirSplit' => 2, 'dirSplit' => 2,
'memKeyLimit' => 20 'memKeyLimit' => 20,
'keyHashFunction' => 'md5'
); );


public function __construct(array $options = array()) public function __construct(array $options = array())
Expand All @@ -91,6 +92,13 @@ public function __construct(array $options = array())
$options['memKeyLimit'] = 0; $options['memKeyLimit'] = 0;
} }


if (function_exists($options['keyHashFunction'])) {
$this->keyHashFunction = $options['keyHashFunction'];
}
else {
$this->keyHashFunction = 'md5';
}

$this->memStoreLimit = (int)$options['memKeyLimit']; $this->memStoreLimit = (int)$options['memKeyLimit'];


$this->checkFileSystemPermissions(); $this->checkFileSystemPermissions();
Expand Down Expand Up @@ -248,7 +256,7 @@ protected function makePath($key = null)
$pathPieces = array(); $pathPieces = array();
$path = $basePath; $path = $basePath;
$len = floor(32 / $this->directorySplit); $len = floor(32 / $this->directorySplit);
$key = \Stash\Utilities::normalizeKeys($key); $key = \Stash\Utilities::normalizeKeys($key, $this->keyHashFunction);


foreach ($key as $index => $value) { foreach ($key as $index => $value) {
if (strpos($value, '@') === 0) { if (strpos($value, '@') === 0) {
Expand Down

0 comments on commit f51fbae

Please sign in to comment.