惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
AI
AI
博客园 - 三生石上(FineUI控件)
腾讯CDC
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
雷峰网
雷峰网
NISL@THU
NISL@THU
S
Schneier on Security
T
Threatpost
T
Tenable Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
IT之家
IT之家
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
C
Cybersecurity and Infrastructure Security Agency CISA
P
Privacy & Cybersecurity Law Blog
I
Intezer
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
T
Threat Research - Cisco Blogs
SecWiki News
SecWiki News
AWS News Blog
AWS News Blog
博客园 - Franky
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Proofpoint News Feed
V
V2EX
Recorded Future
Recorded Future
Microsoft Security Blog
Microsoft Security Blog
S
Secure Thoughts
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
Apple Machine Learning Research
Apple Machine Learning Research
Project Zero
Project Zero
PCI Perspectives
PCI Perspectives
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Cloudbric
Cloudbric
Recent Announcements
Recent Announcements
V
Visual Studio Blog
Hacker News: Ask HN
Hacker News: Ask HN
N
News and Events Feed by Topic
C
CERT Recently Published Vulnerability Notes
The Cloudflare Blog
Forbes - Security
Forbes - Security
C
Cisco Blogs
O
OpenAI News
www.infosecurity-magazine.com
www.infosecurity-magazine.com

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Introducing Selective - Super-Fast Bloom Filter Validation for Laravel Applications
Abdelrahman Dwedar · 2026-06-22 · via DEV Community

I have written about Bloom Filters before in Bloom Filters Applied In Real Life Application - Laravel Prototype and made a prototype for it using Laravel.

Now I'm very pleased to announce that I finally — and after repeated attempts — finished developing the Selective Package!!

Let's go through the journey I took to make this package.

Transitioning from a Prototype to a Generic Package

I recommend reading my earlier blog Bloom Filters Applied In Real Life Application - Laravel Prototype before continuing with this blog, as it explains the internal mechanism of how Bloom Filters work

In my last blog, when I showed the use case for bloom filters and implemented the prototype, I noticed a lack of support for that solution in the Laravel & PHP ecosystems. So I decided to take the initiative and make this package.

It wasn’t hard to implement that as a reusable package since I already made a prototype and it had the core functionality already working correctly, but I got very busy by then, and that’s one thing a lot of people underestimate.

Time management and prioritizing change a lot of things for us developers often. We don’t get paid to make those packages for public use, so we – unintentionally – give lower priority to working on those kinds of things. And under unpleasant circumstances at work, which turned working into a struggle to keep yourself up and running.

Cheerfully, I finally switched gears, and I was able to manage my time to give some time to the research on this package making.

Research Importance in Making Developer Tools

We normally, when working on a business project in a company, have a product research phase (or whatever you want to call it), in that phase, we go deep into the nature of the market of that product we are trying to introduce to the market.

And also, we research the business domains of that product in detail to make a solid plan for the features we need to develop.

I believe that a similar process should be applied to Developer tools as well, but different in the method, as we are not making a business here, and it’s a solution, not a business domain.

What we need to research is the inclusiveness of the tool more. Naturally, we developers might use the same library/package in a project that deals with delivery systems and the exact same library/package in a CRM, or maybe an HR system, etc…

Having that in mind, making our tool as inclusive and generic as possible is something that will indeed make a noticeable difference in the Developer Experience (DX) for the developer using our tool.

In the case of Selective, that part was adding the bloom:seed command. I assumed the developer could add my library after already having a lot of records in the table, and they might need to add those older records as well in the bit array, so having a command to do that made sense in that case.


Solving Database Uniqueness Strain at Scale

At scale, standard uniqueness validations (unique:users,email) run standard SELECT COUNT(*) or EXISTS queries on your database. If you have 10 million users, even with an index, running these checks on every sign-up, profile update, or request can strain database connections.

Selective inserts a Bloom Filter (using a RedisBloom-backed data structure) between the application layer and your primary database.

  • BloomUnique Rule: When a user registers with an email, Selective queries the Redis Bloom filter selective:users:email. If the email is not in the filter (100% certainty), validation passes instantly. If it might be in the filter (probabilistic check), Selective falls back to a standard database check to verify.
  • BloomExists Rule: Similarly, it validates that a record exists (useful for high-volume reference checks).
  • Graceful Error Handling & Fallback: If Redis crashes, is misconfigured, or drops, Selective logs a warning and falls back to database validation. Your application suffers zero downtime.

Package Architecture & Key Code Components

1. Core Service: BloomFilterService

The service layer wraps Redis raw command execution. Because Laravel's default Redis wrapper does not natively implement Bloom commands, we use executeRaw() to run commands like BF.RESERVE, BF.INSERT, BF.EXISTS, BF.MADD, and BF.INFO.

Key implementation details:

  • Auto-Reservation: If auto_reserve is enabled in config/selective.php, the service uses BF.INSERT (which automatically reserves the filter using configured capacity and error rates if the key does not exist) rather than throwing errors.
  • Bulk Operations: Implements addMultiple (BF.MADD / BF.INSERT) and existsMultiple (BF.MEXISTS) to enable efficient bulk seeding.

2. Validation Rules: BloomUnique & BloomExists

Instead of a hardcoded class, rules take table and column arguments dynamically.
For example, inside BloomUnique:

public function validate(string $attribute, mixed $value, Closure $fail): void
{
    $column = $this->column ?? $attribute;
    $bloomKey = "{$this->table}:{$column}";
    $service = app(BloomFilterService::class);

    // If it might exist in the bloom filter
    if ($service->exists($bloomKey, (string) $value)) {
        // Fall back to database check to rule out false positives
        $query = DB::table($this->table)->where($column, $value);

        if ($this->ignoreId !== null) {
            $query->where($this->idColumn, '!=', $this->ignoreId);
        }

        if ($query->exists()) {
            $fail('The :attribute has already been taken.');
        }
    }
}

It supports .ignore($id) out of the box, making update validation simple:

new BloomUnique('users', 'email')->ignore($user->id)

3. Automatic Eloquent Synchronization: HasBloomFilters

To keep the Bloom filter updated in real-time, developers use this trait on their models and define a $bloomFilters property.

class User extends Model
{
    use HasBloomFilters;

    protected array $bloomFilters = ['email', 'username'];
}

The trait registers Eloquent boot hooks (created and updating). On updates, it uses isDirty($column) to only push updated values to Redis.

Note: Since Bloom filters do not support deletion, when a model is deleted from the DB, its value remains in Redis. This is fine because the database fallback handles the resulting false-positive check during validation.

4. Developer Tools: Artisan Commands

  • BloomSeedCommand: Seeds existing tables into Redis in chunks (1000 records at a time) using bulk operations (addMultiple) to initialize existing databases.
  • BloomStatusCommand: Queries BF.INFO to retrieve and format filter properties (Capacity, Size in Bytes, Items Inserted, Expansion Rate) into a neat CLI table.
  • BloomClearCommand: Uses Redis DEL to reset filters manually.

Conclusion

Building Selective has been a highly rewarding journey—from a simple prototype born out of necessity to a robust, generic Laravel package. It stands as a reminder that taking the extra time to prioritize Developer Experience (DX) and thorough research can yield tools that genuinely make our lives easier.

By bridging the gap between application-layer validation and database constraints, Selective ensures your primary database isn't unnecessarily strained during high-traffic spikes. Whether you are dealing with millions of user registrations or high-volume reference checks, the combination of RedisBloom and Laravel's elegant syntax provides a seamless, fail-safe solution that scales with your application.

I encourage you to give it a spin in your next high-volume Laravel project! You can check out the full documentation and source code here:

Explore Selective on GitHub

If you find it useful, dropping a star on the repository would be greatly appreciated. I am also very open to feedback, so feel free to open issues, suggest features, or submit pull requests. Open-source tools thrive on community collaboration.

Thank you for following along with this journey. Happy coding, and may your application validations always be super-fast!