Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Redis Essentials

You're reading from   Redis Essentials Harness the power of Redis to integrate and manage your projects efficiently

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher Packt
ISBN-13 9781784392451
Length 230 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Keys without a namespace


It is good practice to use namespaces when defining your keys in Redis in order to avoid key name collisions and to organize your keys based on your application section or area.

In SQL databases, a namespace can be represented by the database name or the database tables.

Also, in a SQL database, it is reasonable to assume that a database called music-online has tables called album, song, and author.

Redis does not support namespacing. Usually, key name conventions are used to mimic namespaces. A common way of adding namespaces to Redis keys is by prepending a namespace (that is, namespace:key_name). Some Redis clients support addition of a prefix to all Redis keys.

Here are a few examples of key names with namespaces:

  • music-online:song:1

  • music-online:song:2

  • music-online:album:10001:metadata

  • music-online:album:10001:songs

  • music-online:author:123

    Tip

    Multiple databases are not an excuse not to use proper key naming. Always use consistent namespaces.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime