Flintstone - Documentation
Loading a database
Options can be the following:
Option | Description | Default Value |
---|---|---|
|
The directory where the database files are stored (this should be somewhere that is not web accessible) e.g. /path/to/database/ |
current working directory |
|
The database file extension to use |
.dat |
|
Use gzip to compress the database |
false |
|
Whether to cache get() results for faster data retrieval |
true |
|
The formatter class used to encode/decode data |
null |
|
The amount of memory to use before writing to a temporary file |
2097152 |
Flintstone has the following public methods:
Method | Description |
---|---|
|
Retrieve data for the key name. Returns false if it does not exist. |
|
Set data for the key name. Data can be a string, integer, float or array. Will throw an exception if fails to set. |
|
Delete the key name. Will throw an exception if fails to delete. |
|
Empty the database. Will throw an exception if fails to flush. |
|
Returns an array of all of the keys in the database. |
|
Returns all data in the database. |
Changing the formatter
By default Flintstone will encode/decode data using PHP's serialize functions, however you can override this with your own class if you prefer.
Just make sure it implements Flintstone\Formatter\FormatterInterface
and then you can provide it as the formatter option.
If you wish to use JSON as the formatter, Flintstone already ships with this as per the example below:
Changing the cache
To speed up data retrieval Flintstone can store the results of get()
in a cache store. By default this uses a simple array that only persist's for as long as the Flintstone
object exists.
If you want to use your own cache store (such as Memcached) you can pass a class as the cache
option. Just make sure it implements Flintstone\Cache\CacheInterface
.