Internal: Show first 100 characters of cache key for logging purposes.

 Returns a String with a length less than 100 characters.
345156
def peek_key(key)
        case key
        when Integer
          key.to_s
        when String
          key[0, PEEK_SIZE].inspect
        when Array
          str = []
          key.each { |k| str << peek_key(k) }
          str.join(':')[0, PEEK_SIZE]
        else
          peek_key(DigestUtils.pack_urlsafe_base64digest(DigestUtils.digest(key)))
        end
      end
1231594
def get_cache_key(self):
        "  "
        if not self.is_model:
            return None

        pars = ''
        if self.params:
            pars = ','.join(':'.join((smart_str(key), smart_str(self.params[key]))) for key in sorted(self.params.keys()))

        return normalize_key('%s:box:%d:%s:%s' % (
                _get_key(KEY_PREFIX, self.ct, pk=self.obj.pk), settings.SITE_ID, str(self.box_type), pars
            ))
189995
private static String encodeCacheKey(OcspResponseCacheKey ocsp_cache_key)
  {
    try
    {
      DigestCalculator digest = new SHA1DigestCalculator();
      AlgorithmIdentifier algo = digest.getAlgorithmIdentifier();
      ASN1OctetString nameHash = ASN1OctetString.getInstance(ocsp_cache_key.nameHash);
      ASN1OctetString keyHash = ASN1OctetString.getInstance(ocsp_cache_key.keyHash);
      ASN1Integer snumber = new ASN1Integer(ocsp_cache_key.serialNumber);
      CertID cid = new CertID(algo, nameHash, keyHash, snumber);
      return Base64.encodeBase64String(cid.toASN1Primitive().getEncoded());
    }
    catch (Exception ex)
    {
      LOGGER.debug("Failed to encode cache key to base64 encoded cert id");
    }
    return null;
  }
1239520
def _get_cache_size(replace=False):
    """"""

    if not replace:
        size = _cached_search_compile.cache_info().currsize
    else:
        size = _cached_replace_compile.cache_info().currsize
    return size
159125
def _get_cache_contents(self):
        
        if not os.path.isdir(self._path):
            return []

        def sort_key(name):
            path, stamp = self._get_cache_dir(name)
            try:
                return os.stat(stamp).st_mtime
            except OSError:
                return 0

        names = os.listdir(self._path)
        names.sort(key=sort_key, reverse=True)
        return names
626691
def get_cache_key(bucket, name, args, kwargs):
    
    u = ''.join(map(str, (bucket, name, args, kwargs)))
    return 'native_tags.%s' % sha_constructor(u).hexdigest()
948346
public static String getFirstResourceId(final CacheKey key) {
    try {
      if (key instanceof MultiCacheKey) {
        List<CacheKey> keys = ((MultiCacheKey) key).getCacheKeys();
        return secureHashKey(keys.get(0));
      } else {
        return secureHashKey(key);
      }
    } catch (UnsupportedEncodingException e) {
      // This should never happen. All VMs support UTF-8
      throw new RuntimeException(e);
    }
  }
206624
public static Single<Long> length(CacheConfigBean cacheConfigBean, String cacheKey) {
        return SingleRxXian.call(CacheService.CACHE_SERVICE, "cacheListLength", new JSONObject() {{
            put("cacheConfig", cacheConfigBean);
            put("key", cacheKey);
        }}).map(unitResponse -> {
            long length = Objects.requireNonNull(unitResponse.dataToLong());
            return length > 0 ? length : 0;
        });
    }
750302
function getKeys (memcached, cb) {
  var keyArray = []
  var keyLength = 0

  memcached.items().then(function (items) {
    items.forEach(function (item) {
      keyLength += item.data.number

      memcached.cachedump(item.slab_id, item.data.number).then(function (dataSet) {
        dataSet.forEach(function (data) {
          if (data.key) {
            memcached.get(data.key).then(function (val) {
              if (val) {
                keyArray.push(data.key)
              }

              keyLength -= 1

              if (keyLength === 0) {
                cb(null, keyArray)
              }
            })
          }
        })
      })
    })
  }).catch(function (err) {
    cb(err)
  })
}
843247
def get_reply_order_cache_data(comid):
    
    return "%s%s%s%s" % (chr((comid >> 24) % 256), chr((comid >> 16) % 256),
                         chr((comid >> 8) % 256), chr(comid % 256))
81619
private void parseFlexKey(String key) {

        List<String> tokens = CmsStringUtil.splitAsList(key, ';', false);
        Iterator<String> i = tokens.iterator();
        try {
            while (i.hasNext()) {
                String t = i.next();
                String k = null;
                String v = null;
                int idx = t.indexOf('=');
                if (idx >= 0) {
                    k = t.substring(0, idx).trim();
                    if (t.length() > idx) {
                        v = t.substring(idx + 1).trim();
                    }
                } else {
                    k = t.trim();
                }
                m_always = 0;
                if (LOG.isDebugEnabled()) {
                    LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXCACHEKEY_PARSE_FLEXKEY_3, t, k, v));
                }
                switch (CACHE_COMMANDS.indexOf(k)) {
                    case 0: // always
                    case 12: // true
                        m_always = 1;
                        // continue processing (make sure we find a "never" behind "always")
                        break;
                    case 1: // never
                    case 10: // false
                        m_always = -1;
                        // no need for any further processing
                        return;
                    case 2: // uri
                        m_uri = IS_USED; // marks m_uri as being used
                        break;
                    case 3: // user
                        m_user = IS_USED; // marks m_user as being used
                        break;
                    case 4: // params
                        if (v != null) {
                            m_params = parseValueList(v);
                        } else {
                            m_params = Collections.emptySet();
                        }

                        if (m_params.contains(I_CmsResourceLoader.PARAMETER_ELEMENT)) {
                            // workaround for element setting by parameter in OpenCms < 6.0
                            m_element = IS_USED;
                            m_params.remove(I_CmsResourceLoader.PARAMETER_ELEMENT);
                            if (m_params.size() == 0) {
                                m_params = null;
                            }
                        }
                        break;
                    case 5: // no-params
                        if (v != null) {
                            // no-params are present
                            m_noparams = parseValueList(v);
                        } else {
                            // never cache with parameters
                            m_noparams = Collections.emptySet();
                        }
                        break;
                    case 6: // timeout
                        m_timeout = Integer.parseInt(v);
                        break;
                    case 7: // session
                        m_session = parseValueList(v);
                        if (m_session.size() <= 0) {
                            // session must have at last one variable set
                            m_parseError = true;
                        }
                        break;
                    case 8: // schemes
                        m_schemes = parseValueList(v);
                        break;
                    case 9: // ports
                        Set<String> ports = parseValueList(v);
                        m_ports = new HashSet<Integer>(ports.size());
                        for (String p : ports) {
                            try {
                                m_ports.add(Integer.valueOf(p));
                            } catch (NumberFormatException e) {
                                // ignore this number
                            }
                        }
                        break;
                    case 11: // previous parse error - ignore
                        break;
                    case 13: // ip
                        m_ip = IS_USED; // marks ip as being used
                        break;
                    case 14: // element
                        m_element = IS_USED;
                        break;
                    case 15: // locale
                        m_locale = IS_USED;
                        break;
                    case 16: // encoding
                        m_encoding = IS_USED;
                        break;
                    case 17: // site
                        m_site = IS_USED;
                        break;
                    case 18: // attrs
                        if (v != null) {
                            m_attrs = parseValueList(v);
                        } else {
                            m_attrs = null;
                        }
                        break;
                    case 19: // no-attrs
                        if (v != null) {
                            // no-attrs are present
                            m_noattrs = parseValueList(v);
                        } else {
                            // never cache with attributes
                            m_noattrs = Collections.emptySet();
                        }
                        break;
                    case 20: // device
                        m_device = IS_USED; // marks m_device as being used
                        break;
                    case 21: // container element
                        m_containerElement = IS_USED;
                        break;
                    default: // unknown directive, throw error
                        m_parseError = true;
                }
            }
        } catch (Exception e) {
            // any Exception here indicates a parsing error
            if (LOG.isErrorEnabled()) {
                LOG.error(Messages.get().getBundle().key(Messages.LOG_FLEXCACHEKEY_PARSE_ERROR_1, e.toString()), e);
            }
            m_parseError = true;
        }
        if (m_parseError) {
            // If string is invalid set cache to "never"
            m_always = -1;
        }
    }
953021
def validate_key(self, key):
        
        if len(key) > 250:
            raise ValueError(
                "Cache key is longer than the maxmimum 250 characters: {}"
                .format(key),
            )
        return super(MySQLCache, self).validate_key(key)
944884
private static String key2Str_impl(Key k) {
    // check if we are system key
    StringBuilder sb = new StringBuilder(k._kb.length / 2 + 4);
    int i = 0;
    if( k._kb[0] < 32 ) {
      // System keys: hexalate all the leading non-ascii bytes
      sb.append('%');
      int j = k._kb.length - 1;     // Backwards scan for 1st non-ascii
      while( j >= 0 && k._kb[j] >= 32 && k._kb[j] < 128 )
        j--;
      for( ; i <= j; i++ ) {
        byte b = k._kb[i];
        int nib0 = ((b >>> 4) & 15) + '0';
        if( nib0 > '9' ) nib0 += 'A' - 10 - '0';
        int nib1 = ((b >>> 0) & 15) + '0';
        if( nib1 > '9' ) nib1 += 'A' - 10 - '0';
        sb.append((char) nib0).append((char) nib1);
      }
      sb.append('%');
    }
    // Escape the special bytes from 'i' to the end
    return escapeBytes(k._kb, i, sb).toString();
  }
794515
def key_description(self):
        ""
        vk, scan, flags = self._get_key_info()
        desc = ''
        if vk:
            if vk in CODE_NAMES:
                desc = CODE_NAMES[vk]
            else:
                desc = "VK %d"% vk
        else:
            desc = "%s"% self.key

        return desc
169815
private String getCacheKey(String[] keys, CmsDbContext dbc) {

        if (!dbc.getProjectId().isNullUUID()) {
            return "";
        }
        StringBuffer b = new StringBuffer(64);
        int len = keys.length;
        if (len > 0) {
            for (int i = 0; i < len; i++) {
                b.append(keys[i]);
                b.append('_');
            }
        }
        if (dbc.currentProject().isOnlineProject()) {
            b.append("+");
        } else {
            b.append("-");
        }
        return b.toString();
    }
35645
public String getCacheKey(String name, Tree params, String... keys) {
		if (params == null) {
			return name;
		}
		StringBuilder key = new StringBuilder(128);
		key.append(name);
		key.append(':');
		serializeKey(key, params, keys);
		return key.toString();
	}
521422
def util_mic_len(pkt):
    '''  '''
    if (pkt.nwk_seclevel == 0):  # no encryption, no mic
        return 0
    elif (pkt.nwk_seclevel == 1):  # MIC-32
        return 4
    elif (pkt.nwk_seclevel == 2):  # MIC-64
        return 8
    elif (pkt.nwk_seclevel == 3):  # MIC-128
        return 16
    elif (pkt.nwk_seclevel == 4):  # ENC
        return 0
    elif (pkt.nwk_seclevel == 5):  # ENC-MIC-32
        return 4
    elif (pkt.nwk_seclevel == 6):  # ENC-MIC-64
        return 8
    elif (pkt.nwk_seclevel == 7):  # ENC-MIC-128
        return 16
    else:
        return 0