Skip to content

Commit

Permalink
1.23 2022-03-20
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecc-business-account committed Mar 20, 2022
1 parent 581703c commit 2b15ebd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# DocumentStoreOne
A document store for PHP that allows multiples concurrencies. It is a minimalist alternative to MongoDB or CouchDB without the overhead of installing a new service.

It also works a a small footprint database.
It also works as a small footprint database.

[![Build Status](https://travis-ci.org/EFTEC/DocumentStoreOne.svg?branch=master)](https://travis-ci.org/EFTEC/DocumentStoreOne)
[![Packagist](https://img.shields.io/packagist/v/eftec/documentstoreone.svg)](https://packagist.org/packages/eftec/documentstoreone)
Expand Down Expand Up @@ -626,6 +626,8 @@ $doc->insert('csv1',$values);


# Version list
* 1.23 2022-03-20
* **[new]** It allows to obtain an instance (if any) of DocumentStoreOne using the static method DocumentStoreOne::instance()
* 1.22.1 2022-03-12
* getTimeStamp() Fixed: returns a warning if the file does not exist.
* 1.22 2022-03-12
Expand Down
21 changes: 20 additions & 1 deletion lib/DocumentStoreOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* Class DocumentStoreOne
*
* @version 1.22.1 2022-03-12
* @version 1.23 2022-03-20
* @author Jorge Castro Castillo [email protected]
* @link https://github.com/EFTEC/DocumentStoreOne
* @license LGPLv3 or commercial
Expand Down Expand Up @@ -85,6 +85,8 @@ class DocumentStoreOne
protected $autoSerialize;
public $throwable = true;
public $latestError = '';
/** @var DocumentStoreOne */
protected static $instance;
/*protected $memcache;*/
/**
* @var string= 'sequencephp' (snowfake generation),'nextsequence' (generated by a document) or the name of the
Expand Down Expand Up @@ -144,7 +146,24 @@ public function __construct(
. $this->getPath() .
'. You could create the collection with createCollection()');
}
if (self::$instance === null) {
self::$instance = $this;
}
}
/**
* It returns the first instance created DocumentStoreOne or throw an error if the instance is not set.
* @param bool $throwIfNull if true and the instance is not set, then it throws an exception<br>
* if false and the instance is not set, then it returns null
* @return DocumentStoreOne|null
*/
public static function instance(bool $throwIfNull = true): ?DocumentStoreOne
{
if (self::$instance === null && $throwIfNull) {
throw new RuntimeException('instance not created for DocumentStoreOne');
}
return self::$instance;
}


public function isTabular(): bool
{
Expand Down

0 comments on commit 2b15ebd

Please sign in to comment.