PHPackages                             jsidorenko/redcard - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. jsidorenko/redcard

ActiveLibrary[Caching](/categories/caching)

jsidorenko/redcard
==================

Autocomplete implementation using PHP and Redis

v1.1(10y ago)0221MITPHPPHP &gt;=5.3.0

Since Jun 28Pushed 10y ago1 watchersCompare

[ Source](https://github.com/jsidorenko/RedCard-Autocomplete)[ Packagist](https://packagist.org/packages/jsidorenko/redcard)[ Docs](https://github.com/jsidorenko/RedCard-Autocomplete)[ RSS](/packages/jsidorenko-redcard/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

RedCard Autocomplete
====================

[](#redcard-autocomplete)

Autocomplete implementation using PHP+Redis.

Inspired by

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
------------

[](#installation)

Add `mochaka/redcard` as a requirement to `composer.json`:

```
{
    "require": {
        "jsidorenko/redcard": "dev-master"
    }
}
```

Update your packages with `composer update` or install with `composer install`.

### Integration

[](#integration)

You will need to create a Predis Client Instance and provide it to the autocomplete class.

```
    $redis = new Predis\Client(array(
        'scheme' => 'tcp',
        'host'   => 'localhost',
        'port'   => 6379,
    ));

    $autocomplete = new JSidorenko\RedCard\RedisAutocomplete( $redis );
    or
    $autocomplete = new JSidorenko\RedCard\RedisAutocomplete( $redis, "yourDomainPrefix" );

    instead of "yourDomainPrefix" you can write something like "users" or "locations"
```

Basic Usage
-----------

[](#basic-usage)

To store data you must have a unique ID for an item and the phrase that should be searchable.

```
$autocomplete->store(2, "cat");
$autocomplete->store(3, "care");
$autocomplete->store("MYCRAZYID", "caress");
$autocomplete->store(55, "cars");
$autocomplete->store(6, "camera");

$results = $autocomplete->find("car");

var_dump($results)
```

Bins
----

[](#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.

```
$autocomplete->store(2, "Mary", "users");
$autocomplete->store(3, "Sally", "users");
$autocomplete->store(4, "Leo", "users" );

$autocomplete->store(5, "Mary Had A Litte Lamb", "blog-title");
$autocomplete->store(6, "Redis Rocks, A Life Story", "blog-title");

$results = $autocomplete->find("Mary", "users");

// Will only return Mary instead of "Mary Had A Litte Lamb"
```

Interface
---------

[](#interface)

The basic functions that you need to be aware of to utilize RedCard.

- **store**: store a new item to autocomplete

    ```
         store($id, $phrase, $bin = '', $score = 1, $data = NULL)
    ```

    example

    ```
         $autocomplete->store('id123', "Clockwork Orange", "Books", 3, array('author'=>'Anthony Burgess'))
    ```
- **find**: find an item. Searches are cached in a seperate hash.

    ```
         find($phrase, $bin = '', $count = 10, $isCaching = true)
    ```

    example

    ```
         $autocomplete->find("Clock", "Books", 1, true)
    ```
- **find by ID**: find an item by provided ID. Returns null if nothing found.

    ```
         findByID($id, $bin = '')
    ```

    example

    ```
         $autocomplete->findByID('id123')
    ```
- **remove**: remove an item from a bin. Searches are cached in a separate hash.

    ```
         remove($id, $bin = '')
    ```

    example

    ```
         $autocomplete->remove('id123', 'Books')
    ```
- **clear**: clear all items.

    ```
         clear()
    ```

    example

    ```
         $autocomplete->clear()
    ```

License
-------

[](#license)

RedCard Autocomplete is licensed under the [MIT License](http://opensource.org/licenses/MIT). Original Copyright (c) 2011 Rishi Ishairzay, released under the MIT license

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 65.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~281 days

Total

2

Last Release

3733d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c489fbeede368db147b4274846d2384ea5d5f115430e18f2c019ea153b1e60b0?d=identicon)[jsidorenkko](/maintainers/jsidorenkko)

---

Top Contributors

[![zero-is-one](https://avatars.githubusercontent.com/u/201937?v=4)](https://github.com/zero-is-one "zero-is-one (28 commits)")[![rishair](https://avatars.githubusercontent.com/u/225732?v=4)](https://github.com/rishair "rishair (6 commits)")[![aaronflorey](https://avatars.githubusercontent.com/u/948073?v=4)](https://github.com/aaronflorey "aaronflorey (3 commits)")[![jsidorenko](https://avatars.githubusercontent.com/u/5252494?v=4)](https://github.com/jsidorenko "jsidorenko (3 commits)")[![tonypiper](https://avatars.githubusercontent.com/u/206124?v=4)](https://github.com/tonypiper "tonypiper (3 commits)")

---

Tags

searchlaravelautocompleterediscache

### Embed Badge

![Health badge](/badges/jsidorenko-redcard/health.svg)

```
[![Health](https://phpackages.com/badges/jsidorenko-redcard/health.svg)](https://phpackages.com/packages/jsidorenko-redcard)
```

###  Alternatives

[awssat/laravel-visits

Laravel Redis visits counter for Eloquent models

974169.8k2](/packages/awssat-laravel-visits)[vink/nova-cache-card

Manage your application's cache from a handy Laravel Nova dashboard card.

26320.0k1](/packages/vink-nova-cache-card)[byerikas/cache-tags

Allows for Redis/Valkey cache flushing multiple tagged items by a single tag.

1418.0k](/packages/byerikas-cache-tags)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
