Google Antigravity Directory

The #1 directory for Google Antigravity prompts, rules, workflows & MCP servers. Optimized for Gemini 3 agentic development.

Resources

PromptsMCP ServersAntigravity RulesGEMINI.md GuideBest Practices

Company

Submit PromptAntigravityAI.directory

Popular Prompts

Next.js 14 App RouterReact TypeScriptTypeScript AdvancedFastAPI GuideDocker Best Practices

Legal

Privacy PolicyTerms of ServiceContact Us
Featured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver ToolsFeatured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver Tools

© 2026 Antigravity AI Directory. All rights reserved.

The #1 directory for Google Antigravity IDE

This website is not affiliated with, endorsed by, or associated with Google LLC. "Google" and "Gemini" are trademarks of Google LLC.

Antigravity AI Directory
PromptsMCPBest PracticesUse CasesLearn
Home
Prompts
Prisma Accelerate Edge Caching

Prisma Accelerate Edge Caching

Edge-ready database access with Prisma Accelerate for Google Antigravity projects including connection pooling and global caching.

prismaaccelerateedgedatabasecaching
by Antigravity Team
⭐0Stars
.antigravity
# Prisma Accelerate Edge Caching for Google Antigravity

Deploy database access at the edge with Prisma Accelerate in your Google Antigravity IDE projects. This comprehensive guide covers connection pooling, global caching, and edge runtime patterns optimized for Gemini 3 agentic development.

## Prisma Setup

Configure Prisma with Accelerate extension:

```typescript
// prisma/schema.prisma
generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider  = "postgresql"
  url       = env("DATABASE_URL")
  directUrl = env("DIRECT_URL")
}

model Prompt {
  id          String   @id @default(cuid())
  slug        String   @unique
  title       String
  description String
  content     String
  tags        String[]
  authorId    String?
  isApproved  Boolean  @default(false)
  viewCount   Int      @default(0)
  starCount   Int      @default(0)
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt

  @@index([isApproved, createdAt])
}
```

## Client Configuration

Set up Prisma Client with Accelerate:

```typescript
// lib/prisma.ts
import { PrismaClient } from '@prisma/client';
import { withAccelerate } from '@prisma/extension-accelerate';

export const prismaEdge = new PrismaClient().$extends(withAccelerate());

const globalForPrisma = globalThis as unknown as {
  prisma: PrismaClient | undefined;
};

export const prisma =
  globalForPrisma.prisma ??
  new PrismaClient({
    log: process.env.NODE_ENV === 'development' ? ['query'] : [],
  });

if (process.env.NODE_ENV !== 'production') {
  globalForPrisma.prisma = prisma;
}
```

## Caching Strategies

Implement different cache strategies:

```typescript
// lib/queries.ts
import { prismaEdge } from './prisma';

// Short TTL for frequently changing data
export async function getPrompts({ page = 1, limit = 20 }) {
  const offset = (page - 1) * limit;

  const [prompts, total] = await Promise.all([
    prismaEdge.prompt.findMany({
      where: { isApproved: true },
      orderBy: { createdAt: 'desc' },
      take: limit,
      skip: offset,
      cacheStrategy: {
        ttl: 60,      // 1 minute
        swr: 120,     // Stale-while-revalidate for 2 minutes
      },
    }),
    prismaEdge.prompt.count({
      where: { isApproved: true },
      cacheStrategy: { ttl: 60 },
    }),
  ]);

  return { prompts, total, page, limit };
}

// Longer TTL for static content
export async function getPromptBySlug(slug: string) {
  return prismaEdge.prompt.findUnique({
    where: { slug },
    cacheStrategy: {
      ttl: 300,       // 5 minutes
      swr: 600,       // 10 minutes stale-while-revalidate
      tags: [`prompt:${slug}`],
    },
  });
}

// No cache for user-specific data
export async function getUserPrompts(userId: string) {
  return prismaEdge.prompt.findMany({
    where: { authorId: userId },
    orderBy: { createdAt: 'desc' },
    // No cacheStrategy = no caching
  });
}
```

## Edge API Routes

Create edge-compatible API routes:

```typescript
// app/api/prompts/route.ts
import { NextRequest } from 'next/server';
import { getPrompts } from '@/lib/queries';

export const runtime = 'edge';

export async function GET(request: NextRequest) {
  const { searchParams } = new URL(request.url);
  
  const page = Number(searchParams.get('page')) || 1;
  const limit = Number(searchParams.get('limit')) || 20;

  try {
    const result = await getPrompts({ page, limit });
    
    return Response.json(result, {
      headers: {
        'Cache-Control': 'public, s-maxage=60, stale-while-revalidate=120',
      },
    });
  } catch (error) {
    console.error('Failed to fetch prompts:', error);
    return Response.json({ error: 'Failed to fetch prompts' }, { status: 500 });
  }
}
```

## Cache Invalidation

Invalidate cache when data changes:

```typescript
// lib/mutations.ts
import { prismaEdge } from './prisma';

export async function createPrompt(data: {
  title: string;
  description: string;
  content: string;
  tags: string[];
  authorId: string;
}) {
  const slug = data.title.toLowerCase().replace(/[^a-z0-9]+/g, '-');

  const prompt = await prismaEdge.prompt.create({
    data: { ...data, slug },
  });

  // Invalidate list cache
  await prismaEdge.$accelerate.invalidate({
    tags: ['prompts:list'],
  });

  return prompt;
}

export async function updatePrompt(id: string, data: Partial<{
  title: string;
  description: string;
  content: string;
  tags: string[];
}>) {
  const prompt = await prismaEdge.prompt.update({
    where: { id },
    data,
  });

  // Invalidate specific prompt and list caches
  await prismaEdge.$accelerate.invalidate({
    tags: [`prompt:${prompt.slug}`, 'prompts:list'],
  });

  return prompt;
}
```

## Best Practices

1. **Use Accelerate extension** for edge runtime compatibility
2. **Configure cache strategies** based on data volatility
3. **Use tags** for targeted cache invalidation
4. **Set appropriate TTL and SWR** values for your use case
5. **Skip caching** for user-specific or sensitive data
6. **Use transactions** for atomic operations
7. **Monitor cache hit rates** with Prisma Data Platform

When to Use This Prompt

This prisma prompt is ideal for developers working on:

  • prisma applications requiring modern best practices and optimal performance
  • Projects that need production-ready prisma code with proper error handling
  • Teams looking to standardize their prisma development workflow
  • Developers wanting to learn industry-standard prisma patterns and techniques

By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their prisma implementations.

How to Use

  1. Copy the prompt - Click the copy button above to copy the entire prompt to your clipboard
  2. Paste into your AI assistant - Use with Claude, ChatGPT, Cursor, or any AI coding tool
  3. Customize as needed - Adjust the prompt based on your specific requirements
  4. Review the output - Always review generated code for security and correctness
💡 Pro Tip: For best results, provide context about your project structure and any specific constraints or preferences you have.

Best Practices

  • ✓ Always review generated code for security vulnerabilities before deploying
  • ✓ Test the prisma code in a development environment first
  • ✓ Customize the prompt output to match your project's coding standards
  • ✓ Keep your AI assistant's context window in mind for complex requirements
  • ✓ Version control your prompts alongside your code for reproducibility

Frequently Asked Questions

Can I use this prisma prompt commercially?

Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.

Which AI assistants work best with this prompt?

This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.

How do I customize this prompt for my specific needs?

You can modify the prompt by adding specific requirements, constraints, or preferences. For prisma projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...