original_string: public static function hash_key($key, cache_definition $definition) {
          if ($definition->uses_simple_keys()) {
              if (debugging() && preg_match('#[^a-zA-Z0-9_]#', $key)) {
                  throw new coding_exception('Cache definition '.$definition->get_id().' requires simple keys. Invalid key provided.', $key);
              }
              // We put the key first so that we can be sure the start of the key changes.
              return (string)$key . '-' . $definition->generate_single_key_prefix();
          }
          $key = $definition->generate_single_key_prefix() . '-' . $key;
          return sha1($key);
      }
code: public static function hash_key($key, cache_definition $definition) {
          if ($definition->uses_simple_keys()) {
              if (debugging() && preg_match('#[^a-zA-Z0-9_]#', $key)) {
                  throw new coding_exception('Cache definition '.$definition->get_id().' requires simple keys. Invalid key provided.', $key);
              }
              // We put the key first so that we can be sure the start of the key changes.
              return (string)$key . '-' . $definition->generate_single_key_prefix();
          }
          $key = $definition->generate_single_key_prefix() . '-' . $key;
          return sha1($key);
      }
code_tokens: public static function hash_key ( $ key , cache_definition $ definition ) { if ( $ definition -> uses_simple_keys ( ) ) { if ( debugging ( ) && preg_match ( '#[^a-zA-Z0-9_]#' , $ key ) ) { throw new coding_exception ( 'Cache definition ' . $ definition -> get_id ( ) . ' requires simple keys. Invalid key provided.' , $ key ) ; } // We put the key first so that we can be sure the start of the key changes. return ( string ) $ key . '-' . $ definition -> generate_single_key_prefix ( ) ; } $ key = $ definition -> generate_single_key_prefix ( ) . '-' . $ key ; return sha1 ( $ key ) ; }
docstring: Hashes a descriptive key to make it shorter and still unique.
  @param string|int $key
  @param cache_definition $definition
  @return string
docstring_tokens: Hashes a descriptive key to make it shorter and still unique .