Aller au contenu

API

Les méthodes répertoriées ici sont les méthodes API documentées dans les versions 0.5. Certaines classes exposent d’autres méthodes publiques pour permettre aux moteurs storh de coopérer en interne ; considérez-les comme des détails d’implémentation sauf si elles figurent sur cette page.

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

Nécessite ext-pdo (pilote sqlite ou mysql) ou 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

Implémentez cette interface (et SqlMirrorStatement) pour faire fonctionner SqlMirror avec une couche de base de données personnalisée. PdoSqlMirrorConnection et MysqliSqlMirrorConnection sont les implémentations incluses.

  • 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