Variant HHVM_FUNCTION(apc_store,
                      const Variant& key_or_array,
                      const Variant& var /* = null */,
                      int64_t ttl /* = 0 */) {
  if (!apcExtension::Enable) return Variant(false);

  if (key_or_array.isArray()) {
    Array valuesArr = key_or_array.toArray();

    for (ArrayIter iter(valuesArr); iter; ++iter) {
      Variant key = iter.first();
      if (!key.isString()) {
        throw_invalid_argument("apc key: (not a string)");
        return Variant(false);
      }
      Variant v = iter.second();
      apc_store().set(key.toString(), v, ttl);
    }

    return Variant(ArrayData::Create());
  }

  if (!key_or_array.isString()) {
    throw_invalid_argument("apc key: (not a string)");
    return Variant(false);
  }
  String strKey = key_or_array.toString();
  apc_store().set(strKey, var, ttl);
  return Variant(true);
}