Μετάβαση στο περιεχόμενο

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