Saltar al contenido

API

Los métodos que se enumeran aquí forman la API documentada de las versiones 0.5. Algunas clases exponen métodos públicos adicionales para que los motores storh puedan colaborar internamente; considéralos detalles de implementación, salvo que aparezcan en esta página.

StorageRoot

  • StorageRoot::at(string $root): StorageRoot
  • StorageRoot::resolve(string $root, string $namespace = 'runtime-storage'): string
  • path(string $namespace = 'runtime-storage'): string
  • root(): string

DocStore

Alias de DocPerFileStore.

  • put(array $data, ?string $id = null): StorageRecord
  • putMany(iterable $records): array
  • putStream(iterable $records): int
  • get(string $id): ?StorageRecord
  • delete(string $id): void
  • stream(?RecordQuery $query = null): Generator
  • query(): QueryBuilder
  • indexes(): DocStoreIndexManager
  • reindex(): array
  • stats(): array
  • health(): array
  • verify(): array
  • repair(): array
  • compact(): array
  • importJsonl(string $path): int
  • exportJsonl(string $path): int
  • path_for_id(string $id): string

SegmentedLog

Alias de SegmentedLogStore.

  • put(array $data, ?string $id = null): StorageRecord
  • appendMany(iterable $records): array
  • appendStream(iterable $records): int
  • get(string $id): ?StorageRecord
  • delete(string $id): void
  • stream(?RecordQuery $query = null): Generator
  • query(): QueryBuilder
  • retain(): SegmentedLogRetention
  • compact(): void
  • recover(): void
  • state_index(): array
  • stats(): array
  • health(): array
  • verify(): array
  • repair(): array

Queue

Alias de LogQueue.

  • enqueue(array $payload, ?string $id = null): string
  • enqueueMany(iterable $jobs): array
  • claim(): ?StorageRecord
  • claimMany(int $limit): array
  • complete(string $id, bool $keep_done = true): void
  • completeMany(iterable $ids, bool $keep_done = true): int
  • requeue_timed_out(int $timeout_seconds): int
  • purgeDone(int $olderThanSeconds = 0): int
  • counts(): array
  • stats(): array
  • health(): array
  • verify(): array
  • repair(int $processingTimeoutSeconds = 3600): array

QueryBuilder

  • where(string $field): QueryFieldBuilder
  • andWhere(callable $callback): QueryBuilder
  • orWhere(callable $callback): QueryBuilder
  • orderBy(string $field, string $direction = 'asc'): QueryBuilder
  • limit(int $limit): QueryBuilder
  • cursor(string $id): QueryBuilder
  • page(int $size): QueryBuilder
  • get(): array
  • first(): ?StorageRecord
  • count(): int
  • explain(): array

DocStoreIndexManager

  • field(string $field): DocStoreIndexFieldBuilder
  • define_field(string $field, bool $unique = false, bool $range = false): DocStoreIndexManager
  • apply_schema(Schema $schema): DocStoreIndexManager
  • sync(bool $rebuild = true): void
  • rebuild(): array
  • definitions(): array

Schema

  • Schema::collection(string $collection): Schema
  • string(string $field): SchemaFieldBuilder
  • int(string $field): SchemaFieldBuilder
  • float(string $field): SchemaFieldBuilder
  • bool(string $field): SchemaFieldBuilder
  • mixed(string $field): SchemaFieldBuilder
  • required(array $fields): Schema
  • validate(array $data): void

Cache

  • Cache::memory(int $maxEntries = 10000, ?int $maxBytes = null): CacheInterface
  • Cache::apcu(string $prefix = 'storh'): CacheInterface
  • Cache::null(): CacheInterface

CacheValidation

  • CacheValidation::HASH
  • CacheValidation::STAT
  • CacheValidation::TRUST

SqlMirror

Requiere ext-pdo (controlador sqlite o mysql) o ext-mysqli.

  • new SqlMirror(PDO|mysqli|SqlMirrorConnection $connection, string $prefix = 'storh_', ?string $driver = null)
  • collection(FileStoreInterface $store, string $name, ?Schema $schema = null): SqlMirror
  • install(): void
  • uninstall(): void
  • push(?string $name = null): array
  • flush(string $name, array $ids): array
  • pull(?string $name = null): array
  • verify(): array
  • rebuild(?string $name = null): array
  • table(string $name): string

SqlMirrorConnection

Implementa esta interfaz (y SqlMirrorStatement) para usar SqlMirror mediante una capa de base de datos personalizada. PdoSqlMirrorConnection y MysqliSqlMirrorConnection son las implementaciones incluidas.

  • driver(): string
  • execute(string $sql): void
  • rows(string $sql): Generator
  • statement(string $sql): SqlMirrorStatement
  • begin(): void
  • commit(): void
  • rollback(): void
  • in_transaction(): bool

RecordQuery

  • RecordQuery::all(): RecordQuery
  • after(string $id): RecordQuery
  • time_range_ms(?int $from_ms, ?int $until_ms): RecordQuery
  • where_equal(string $field, mixed $value): RecordQuery
  • limit(int $limit): RecordQuery
  • continue_on_error(callable $handler): RecordQuery
  • on_segment_open(callable $handler): RecordQuery

StorageRecord

  • id(): string
  • data(): array