Download the PHP package scottchiefbaker/cache_sqlite without Composer
On this page you can find all versions of the php package scottchiefbaker/cache_sqlite. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download scottchiefbaker/cache_sqlite
More information about scottchiefbaker/cache_sqlite
Files in scottchiefbaker/cache_sqlite
Package cache_sqlite
Short Description PHP object caching system with a SQLite backend store and automatic content expiration. Cache is stored using a SQLite database and persists on disk.
License MIT
Homepage https://github.com/scottchiefbaker/php-sqlite-cache
Informations about the package cache_sqlite
๐งฐ PHP SQLite object cache
PHP object caching system with a SQLite backend store and automatic content expiration.
๐ ๏ธ Requirements
- PHP 8.3+
- PDO functions in PHP
- SQLite functions in PHP
- JSON functions in PHP
๐ Optional components
- igbinary
- msgpack
If either igbinary or msgpack functions are available we will automatically use them as the serialization storage method in the database. If neither are available we fall back to JSON.
โจ Usage
๐ฏ Methods
get($key)
Returns stored object. Returns null if the key is missing or expired.
set($key, $object, $expire_time)
Store an object in cache. Returns status of storage. $expire_time accepts these forms:
- a number less than
100000โ cache for that many seconds - a number more than
100000โ cache until that unixtime
delete($key)
Remove an item from cache. Returns status of deletion.
cached_item_count()
Return the number of active items in the cache.
cached_item_keys()
Return array of all the active items in the cache.
remove_expired_entries($vacuum_db)
Remove all expired items from cache. If $vacuum_db is set, the DB will be vacuumed after removal.
empty_cache()
Remove all items from the cache.
๐งน Cleanup
Over time objects will be added and deleted from the cache. This may create
database fragmentation. It might be a good idea to VACUUM the DB every
so often. We have provided a method to do this:
๐ Real World Example
๐ฅฝ Testing
The unit tests are a standalone PHP script with no dependencies beyond PHP itself:
The igbinary and msgpack tests are skipped automatically when those extensions are not loaded.