Download the PHP package jsidorenko/redcard without Composer
On this page you can find all versions of the php package jsidorenko/redcard. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jsidorenko/redcard
More information about jsidorenko/redcard
Files in jsidorenko/redcard
Package redcard
Short Description Autocomplete implementation using PHP and Redis
License MIT
Homepage https://github.com/jsidorenko/RedCard-Autocomplete
Informations about the package redcard
RedCard Autocomplete
Autocomplete implementation using PHP+Redis.
Inspired by https://github.com/seatgeek/soulmate
This library handles a basic implementation of autocomplete with sorted results (according to "scores") as well as arbitrary metadata for results. Also has the ability to separate different autocomplete databases in to "bins" (e.g. have separate bins "users" and another for "videos" so when querying against "users" it doesn't show results from "videos")
Installation
Add mochaka/redcard
as a requirement to composer.json
:
Update your packages with composer update
or install with composer install
.
Integration
You will need to create a Predis Client Instance and provide it to the autocomplete class.
Basic Usage
To store data you must have a unique ID for an item and the phrase that should be searchable.
Bins
Different types of data can be distinguished from one another through bins. Each bin has its own name and when searching and removing they will not conflict with one another.
Interface
The basic functions that you need to be aware of to utilize RedCard.
-
store: store a new item to autocomplete
example
-
find: find an item. Searches are cached in a seperate hash.
example
-
find by ID: find an item by provided ID. Returns null if nothing found.
example
-
remove: remove an item from a bin. Searches are cached in a separate hash.
example
-
clear: clear all items.
example
License
RedCard Autocomplete is licensed under the MIT License. Original Copyright (c) 2011 Rishi Ishairzay, released under the MIT license