انتقل إلى المحتوى

API

الطرق المذكورة هنا هي واجهة API الموثقة لإصدارات 0.5. تكشف بعض الأصناف عن طرق عامة إضافية كي تتعاون محركات storh داخليًا؛ تعامل معها كتفاصيل تنفيذية ما لم تُذكر في هذه الصفحة.

StorageRoot

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

DocStore

اسم مستعار لـ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

اسم مستعار لـ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

اسم مستعار لـ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

يتطلب ext-pdo (مشغّل sqlite أو mysql) أو 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

طبّق هذه الواجهة (وSqlMirrorStatement) لتشغيل SqlMirror عبر طبقة قاعدة بيانات مخصصة. PdoSqlMirrorConnection وMysqliSqlMirrorConnection هما التطبيقان المضمّنان.

  • 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