"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_primordials_error = require('../primordials/error.js');
const require_primordials_string = require('../primordials/string.js');
const require_paths_socket = require('../paths/socket.js');
const require_cacache__internal = require('./_internal.js');

//#region src/cacache/read.ts
/**
* @file Cache read entrypoints — `get` (throws on miss) and `safeGet` (returns
*   `undefined` on miss). Both reject keys containing wildcards; bulk reads go
*   through `clear` / `ls` patterns.
*/
/**
* Get data from the Socket shared cache by key.
*
* @example
*   ;```typescript
*   const entry = await get('socket-sdk:scans:abc123')
*   console.log(entry.data.toString('utf8'))
*   ```
*
* @throws {Error} When cache entry is not found.
* @throws {TypeError} If key contains wildcards (*)
*/
async function get(key, options) {
	if (require_primordials_string.StringPrototypeIncludes(key, "*")) throw new require_primordials_error.TypeErrorCtor("Cache key cannot contain wildcards (*). Wildcards are only supported in clear({ prefix: \"pattern*\" }).");
	/* c8 ignore next - External cacache call */
	return await require_cacache__internal.getCacache().get(require_paths_socket.getSocketCacacheDir(), key, options);
}
/**
* Get data from the Socket shared cache by key without throwing.
*
* @example
*   ;```typescript
*   const entry = await safeGet('socket-sdk:scans:abc123')
*   if (entry) {
*     console.log(entry.data.toString('utf8'))
*   }
*   ```
*/
async function safeGet(key, options) {
	try {
		return await get(key, options);
	} catch {
		return;
	}
}

//#endregion
exports.get = get;
exports.safeGet = safeGet;