Permalink
Browse files

FIX: allow the FileSystem driver to configure the key hashing function.

  • Loading branch information...
1 parent 24bbc64 commit f51fbae24bfb4e21d6116c8218f564c208f79324 @pwhelan pwhelan committed Feb 19, 2013
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/Stash/Driver/FileSystem.php
View
12 src/Stash/Driver/FileSystem.php
@@ -68,7 +68,8 @@ class FileSystem implements DriverInterface
protected $defaultOptions = array('filePermissions' => 0660,
'dirPermissions' => 0770,
'dirSplit' => 2,
- 'memKeyLimit' => 20
+ 'memKeyLimit' => 20,
+ 'keyHashFunction' => 'md5'
);
public function __construct(array $options = array())
@@ -91,6 +92,13 @@ public function __construct(array $options = array())
$options['memKeyLimit'] = 0;
}
+ if (function_exists($options['keyHashFunction'])) {
+ $this->keyHashFunction = $options['keyHashFunction'];
+ }
+ else {
+ $this->keyHashFunction = 'md5';
+ }
+
$this->memStoreLimit = (int)$options['memKeyLimit'];
$this->checkFileSystemPermissions();
@@ -248,7 +256,7 @@ protected function makePath($key = null)
$pathPieces = array();
$path = $basePath;
$len = floor(32 / $this->directorySplit);
- $key = \Stash\Utilities::normalizeKeys($key);
+ $key = \Stash\Utilities::normalizeKeys($key, $this->keyHashFunction);
foreach ($key as $index => $value) {
if (strpos($value, '@') === 0) {

0 comments on commit f51fbae

Please sign in to comment.