SSM 是如何生存Key的?

源码中有一个接口:KeyProvider的 方法 String generateKey(final Object keyObject);

/**
     * From the supplied object, create a (no-whitespace) part of the key by which a value will be stored in Memcached.
     * (Hint: This value, plus the Namespace value, plus optional other key should be no longer than 250 characters.)
     * 
     * @param keyObject
     * @return
     */
    String generateKey(final Object keyObject);

根据CacheMethod 返回的值,已经斜线,命名空间生成key

private String buildCacheKey(final String[] objectIds, final String namespace) {
        if (objectIds.length == 1) {
            checkKeyPart(objectIds[0]);
            return namespace + SEPARATOR + objectIds[0];
        }

        StringBuilder cacheKey = new StringBuilder(namespace);
        cacheKey.append(SEPARATOR);
        for (String id : objectIds) {
            checkKeyPart(id);
            cacheKey.append(id);
            cacheKey.append(ID_SEPARATOR);
        }

        cacheKey.deleteCharAt(cacheKey.length() - 1);
        return cacheKey.toString();
    }
原文地址:https://www.cnblogs.com/pan2011/p/3650302.html