PHPackages                             natsumework/redis-autocomplete - 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. natsumework/redis-autocomplete

ActiveLibrary[Caching](/categories/caching)

natsumework/redis-autocomplete
==============================

Provide an easy way for your laravel app to use redis to speed up autocomplete queries.

1.1.0(2y ago)37.9k↓50%MITPHPPHP ^7.3 || ^8.0

Since Feb 6Pushed 2y ago1 watchersCompare

[ Source](https://github.com/natsumework/redis-autocomplete)[ Packagist](https://packagist.org/packages/natsumework/redis-autocomplete)[ RSS](/packages/natsumework-redis-autocomplete/feed)WikiDiscussions main Synced 1mo ago

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

Redis Autocomplete for laravel
==============================

[](#redis-autocomplete-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/715487c6704d86319660052fe4b22f9fd97aee8d38bd3403f2932a2290241d51/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e617473756d65776f726b2f72656469732d6175746f636f6d706c6574652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/natsumework/redis-autocomplete)[![Test Status](https://camo.githubusercontent.com/856ce9617e682de178a7918f2077020b6edd4749b94878bc7fd0ba4c1f8c3a8f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e617473756d65776f726b2f72656469732d6175746f636f6d706c6574652f746573742e796d6c3f6272616e63683d6d61696e)](https://camo.githubusercontent.com/856ce9617e682de178a7918f2077020b6edd4749b94878bc7fd0ba4c1f8c3a8f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e617473756d65776f726b2f72656469732d6175746f636f6d706c6574652f746573742e796d6c3f6272616e63683d6d61696e)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/d6f1144c0420e012aa0348fe7f2320b1cd578256a227e703cc2a8fe4651755b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e617473756d65776f726b2f72656469732d6175746f636f6d706c6574652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/natsumework/redis-autocomplete)

Provide an easy way for your laravel app to use redis to speed up autocomplete queries.

Contents
--------

[](#contents)

- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Changelog](#changelog)
- [Testing](#testing)
- [Security](#security)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

Installation
------------

[](#installation)

Install this package via composer:

```
composer require natsumework/redis-autocomplete

```

Publish the configuration file to `config/redis-autocomplete.php`:

```
php artisan vendor:publish --provider="Natsumework\RedisAutocomplete\AutoCompleteServiceProvider"

```

Configuration
-------------

[](#configuration)

`config/redis-autocomplete.php`

```
return [
    /*
    |--------------------------------------------------------------------------
    | Redis Connection
    |--------------------------------------------------------------------------
    |
    | Your application's config/database.php configuration file allows you
    | to define multiple Redis connections / servers.
    | Here you may specify the connection you want to use.
    |
    | To specify an instance of the default Redis connection,
    | you may set the value to null.
    */
    'connection' => 'default',

    /*
    |--------------------------------------------------------------------------
    | Cache Key Prefix
    |--------------------------------------------------------------------------
    |
    | When utilizing a RAM based store such as APC or Memcached, there might
    | be other applications utilizing the same cache. So, we'll specify a
    | value to get prefixed to all our keys so we can avoid collisions.
    |
    */
    'prefix' => 'redis-autocomplete',

    /*
    |--------------------------------------------------------------------------
    | Storage time
    |--------------------------------------------------------------------------
    |
    | Specifies that phrases will expire in a few seconds.
    | If set to null, phrases will be stored indefinitely.
    |
    */
    'ttl' => 60 * 60 * 24
];

```

Usage
-----

[](#usage)

#### Add phrases

[](#add-phrases)

Note:

- The phrase must contain `id` and `name` as attributes
- phrase`id` must be unique
- When searching, it will be searched by phrase `name`
- You may specify the `score` attribute of phrase to sort the phrases, and the search results will be retrieved in descending order of score.
    If the score is not specified, the default will be 0
- You can add any other attributes to the pharse

```
$phrases = [
    [
        'id' => 1, // required
        'name' => 'laravel' // required
    ],
    [
        'id' => 2,
        'name' => 'redis autocomplete',
        'score' => 10, // default is 0
        'custom_column_1' => 'column 1',
        'custom_column_2' => ['item 1', 'item 2'],
        ...
    ]
];

// addPhrases(string $name, $phrases)
Autocomplete::addPhrases('my-phrases', $phrases);

```

You may also use [collections](https://laravel.com/docs/master/collections)

```
$phrases = collect([
    [
        'id' => 1,
        'name' => 'laravel'
    ],
    [
        'id' => 2,
        'name' => 'redis autocomplete'
    ]
]);

Autocomplete::addPhrases('my-phrases-collection', $phrases);

```

or use [Eloquent Collections](https://laravel.com/docs/master/eloquent-collections)

```
// users must contain `id` and `name` as attributes
$phrases = User::all();

Autocomplete::addPhrases('my-users', $phrases);

```

#### Search

[](#search)

```
// array search(string $name, string $keyword, int $limit = 10)
$result = Autocomplete::search('my-phrases', 'keyword', 10);

```

#### Remove phrase

[](#remove-phrase)

Note that the `id` and `name` of the phrase must be the same as when it was added

```
// removePhrase(string $name, $phrase)

$phrase = [
    'id' => 1,
    'name' => 'laravel'
]

Autocomplete::removePhrase('my-phrases', $phrase)

```

#### Connection

[](#connection)

You may obtain a connection to a specific Redis connection using the Autocomplete facade's connection method

```
Autocomplete::connection('autocomplete')
    ->addPhrases($name, $phrases);

Autocomplete::connection('autocomplete')
    ->search($name, $keyword);

```

#### Ttl

[](#ttl)

You may obtain a ttl to a specific expiration using the Autocomplete facade's ttl method

```
Autocomplete::ttl(60 * 60)
    ->addPhrases($name, $phrases);

```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [natsumework](https://github.com/natsumework)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~1148 days

Total

2

Last Release

779d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23622184?v=4)[natsumework](/maintainers/natsumework)[@natsumework](https://github.com/natsumework)

---

Top Contributors

[![natsumework](https://avatars.githubusercontent.com/u/23622184?v=4)](https://github.com/natsumework "natsumework (7 commits)")

---

Tags

autocompletelaravelredisredis-autocompletelaravelautocompleteredis

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/natsumework-redis-autocomplete/health.svg)

```
[![Health](https://phpackages.com/badges/natsumework-redis-autocomplete/health.svg)](https://phpackages.com/packages/natsumework-redis-autocomplete)
```

###  Alternatives

[namoshek/laravel-redis-sentinel

An extension of Laravels Redis driver which supports connecting to a Redis master through Redis Sentinel.

38679.0k](/packages/namoshek-laravel-redis-sentinel)[monospice/laravel-redis-sentinel-drivers

Redis Sentinel integration for Laravel and Lumen.

103830.5k](/packages/monospice-laravel-redis-sentinel-drivers)[yangusik/laravel-balanced-queue

Laravel queue management with load balancing between partitions (user groups)

786.4k](/packages/yangusik-laravel-balanced-queue)[vetruvet/laravel-phpredis

Use phpredis as the redis connection in Laravel

43123.7k](/packages/vetruvet-laravel-phpredis)[ginnerpeace/laravel-redis-lock

Simple redis distributed locks for Laravel.

15114.4k](/packages/ginnerpeace-laravel-redis-lock)[huangdijia/laravel-redis-ide-helper

Redis ide-helper for Laravel.

1243.3k](/packages/huangdijia-laravel-redis-ide-helper)

PHPackages © 2026

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