0
# Namespace Support
1
2
Namespace functionality for organizing MMKV instances with custom root directories, providing data isolation and organizational capabilities.
3
4
## Capabilities
5
6
### Namespace Creation
7
8
Create and manage MMKV namespaces with custom root directories for better data organization.
9
10
```java { .api }
11
/**
12
* Create a NameSpace with custom root directory.
13
* @param dir The customize root directory of the NameSpace
14
* @return A NameSpace instance with custom root dir
15
* @throws RuntimeException if there's a runtime error
16
*/
17
public static NameSpace nameSpace(String dir);
18
19
/**
20
* Get the default NameSpace using the global MMKV root directory.
21
* @return The default NameSpace instance
22
* @throws RuntimeException if there's a runtime error
23
*/
24
public static NameSpace defaultNameSpace();
25
26
/**
27
* Get the root directory of this NameSpace.
28
* @return The root folder path of this NameSpace
29
*/
30
public String getRootDir();
31
```
32
33
**Usage Example:**
34
35
```java
36
import com.tencent.mmkv.MMKV;
37
import com.tencent.mmkv.NameSpace;
38
39
public class NameSpaceExample {
40
41
public void demonstrateNameSpaces(Context context) {
42
// Create custom namespaces for different data types
43
File userDataDir = new File(context.getFilesDir(), "user_data");
44
File cacheDir = new File(context.getCacheDir(), "mmkv_cache");
45
File configDir = new File(context.getFilesDir(), "app_config");
46
47
// Ensure directories exist
48
userDataDir.mkdirs();
49
cacheDir.mkdirs();
50
configDir.mkdirs();
51
52
// Create namespaces
53
NameSpace userNameSpace = MMKV.nameSpace(userDataDir.getAbsolutePath());
54
NameSpace cacheNameSpace = MMKV.nameSpace(cacheDir.getAbsolutePath());
55
NameSpace configNameSpace = MMKV.nameSpace(configDir.getAbsolutePath());
56
NameSpace defaultNameSpace = MMKV.defaultNameSpace();
57
58
// Verify namespace directories
59
Log.d("MMKV", "User namespace root: " + userNameSpace.getRootDir());
60
Log.d("MMKV", "Cache namespace root: " + cacheNameSpace.getRootDir());
61
Log.d("MMKV", "Config namespace root: " + configNameSpace.getRootDir());
62
Log.d("MMKV", "Default namespace root: " + defaultNameSpace.getRootDir());
63
}
64
}
65
```
66
67
### Instance Creation within Namespaces
68
69
Create MMKV instances within specific namespaces for organized data storage.
70
71
```java { .api }
72
/**
73
* Create an MMKV instance with unique ID in this namespace (single-process mode).
74
* @param mmapID The unique ID of the MMKV instance
75
* @return The MMKV instance in this namespace
76
* @throws RuntimeException if there's a runtime error
77
*/
78
public MMKV mmkvWithID(String mmapID);
79
80
/**
81
* Create an MMKV instance in single-process or multi-process mode.
82
* @param mmapID The unique ID of the MMKV instance
83
* @param mode The process mode (SINGLE_PROCESS_MODE or MULTI_PROCESS_MODE)
84
* @return The MMKV instance in this namespace
85
* @throws RuntimeException if there's a runtime error
86
*/
87
public MMKV mmkvWithID(String mmapID, int mode);
88
89
/**
90
* Create an MMKV instance with expected capacity.
91
* @param mmapID The unique ID of the MMKV instance
92
* @param mode The process mode
93
* @param expectedCapacity The file size expected when opening or creating file
94
* @return The MMKV instance in this namespace
95
* @throws RuntimeException if there's a runtime error
96
*/
97
public MMKV mmkvWithID(String mmapID, int mode, long expectedCapacity);
98
99
/**
100
* Create an MMKV instance with encryption key.
101
* @param mmapID The unique ID of the MMKV instance
102
* @param mode The process mode
103
* @param cryptKey The encryption key (no more than 16 bytes)
104
* @return The MMKV instance in this namespace
105
* @throws RuntimeException if there's a runtime error
106
*/
107
public MMKV mmkvWithID(String mmapID, int mode, String cryptKey);
108
109
/**
110
* Create an MMKV instance with all customize settings.
111
* @param mmapID The unique ID of the MMKV instance
112
* @param mode The process mode
113
* @param cryptKey The encryption key
114
* @param expectedCapacity The file size expected
115
* @return The MMKV instance in this namespace
116
* @throws RuntimeException if there's a runtime error
117
*/
118
public MMKV mmkvWithID(String mmapID, int mode, String cryptKey, long expectedCapacity);
119
```
120
121
**Usage Example:**
122
123
```java
124
public class NameSpaceInstanceExample {
125
126
private NameSpace userNameSpace;
127
private NameSpace cacheNameSpace;
128
private NameSpace configNameSpace;
129
130
public void setupNameSpaces(Context context) {
131
// Create organized directory structure
132
File baseDir = context.getFilesDir();
133
134
userNameSpace = MMKV.nameSpace(new File(baseDir, "users").getAbsolutePath());
135
cacheNameSpace = MMKV.nameSpace(new File(baseDir, "cache").getAbsolutePath());
136
configNameSpace = MMKV.nameSpace(new File(baseDir, "config").getAbsolutePath());
137
}
138
139
public void demonstrateOrganizedStorage() {
140
// User data in user namespace
141
MMKV userProfile = userNameSpace.mmkvWithID("profile");
142
MMKV userSettings = userNameSpace.mmkvWithID("settings");
143
MMKV userHistory = userNameSpace.mmkvWithID("history", MMKV.SINGLE_PROCESS_MODE, 1024 * 1024);
144
145
// Cache data in cache namespace (temporary, can be cleared)
146
MMKV imageCache = cacheNameSpace.mmkvWithID("images");
147
MMKV apiCache = cacheNameSpace.mmkvWithID("api_responses", MMKV.SINGLE_PROCESS_MODE, 2 * 1024 * 1024);
148
MMKV tempData = cacheNameSpace.mmkvWithID("temp", MMKV.SINGLE_PROCESS_MODE);
149
150
// Configuration in config namespace (encrypted for security)
151
MMKV appConfig = configNameSpace.mmkvWithID("app", MMKV.SINGLE_PROCESS_MODE, "config-key");
152
MMKV serverConfig = configNameSpace.mmkvWithID("server", MMKV.MULTI_PROCESS_MODE, "server-key");
153
154
// Store data in organized manner
155
storeUserData(userProfile, userSettings, userHistory);
156
storeCacheData(imageCache, apiCache, tempData);
157
storeConfigData(appConfig, serverConfig);
158
}
159
160
private void storeUserData(MMKV profile, MMKV settings, MMKV history) {
161
// User profile data
162
profile.encode("user_id", 12345);
163
profile.encode("username", "john_doe");
164
profile.encode("email", "john@example.com");
165
166
// User settings
167
settings.encode("theme", "dark");
168
settings.encode("notifications", true);
169
settings.encode("language", "en");
170
171
// User history
172
history.encode("last_login", System.currentTimeMillis());
173
history.encode("session_count", history.decodeInt("session_count", 0) + 1);
174
175
Log.d("MMKV", "User data stored in user namespace");
176
}
177
178
private void storeCacheData(MMKV imageCache, MMKV apiCache, MMKV tempData) {
179
// Image cache
180
imageCache.encode("profile_image_url", "https://example.com/profile.jpg");
181
imageCache.encode("cache_timestamp", System.currentTimeMillis());
182
183
// API cache
184
apiCache.encode("user_data_response", "{\"id\": 123, \"name\": \"John\"}");
185
apiCache.encode("api_cache_expiry", System.currentTimeMillis() + 3600000); // 1 hour
186
187
// Temporary data
188
tempData.encode("temp_session_id", "temp_" + System.currentTimeMillis());
189
190
Log.d("MMKV", "Cache data stored in cache namespace");
191
}
192
193
private void storeConfigData(MMKV appConfig, MMKV serverConfig) {
194
// App configuration (encrypted)
195
appConfig.encode("api_key", "secret-api-key-12345");
196
appConfig.encode("debug_mode", BuildConfig.DEBUG);
197
appConfig.encode("app_version", BuildConfig.VERSION_NAME);
198
199
// Server configuration (encrypted, multi-process for service access)
200
serverConfig.encode("server_url", "https://api.example.com");
201
serverConfig.encode("timeout_seconds", 30);
202
serverConfig.encode("retry_count", 3);
203
204
Log.d("MMKV", "Config data stored in config namespace (encrypted)");
205
}
206
}
207
```
208
209
### Namespace File Operations
210
211
Perform file operations within specific namespaces.
212
213
```java { .api }
214
/**
215
* Backup one MMKV instance within this namespace to destination directory.
216
* @param mmapID The MMKV ID to backup
217
* @param dstDir The backup destination directory
218
* @return True if backup successful
219
*/
220
public boolean backupOneToDirectory(String mmapID, String dstDir);
221
222
/**
223
* Restore one MMKV instance within this namespace from source directory.
224
* @param mmapID The MMKV ID to restore
225
* @param srcDir The restore source directory
226
* @return True if restore successful
227
*/
228
public boolean restoreOneMMKVFromDirectory(String mmapID, String srcDir);
229
230
/**
231
* Check whether the MMKV file is valid within this namespace.
232
* @param mmapID The unique ID of the MMKV instance
233
* @return True if file is valid
234
*/
235
public boolean isFileValid(String mmapID);
236
237
/**
238
* Remove the storage of the MMKV within this namespace.
239
* @param mmapID The unique ID of the MMKV instance
240
* @return True if removal successful
241
*/
242
public boolean removeStorage(String mmapID);
243
244
/**
245
* Check existence of the MMKV file within this namespace.
246
* @param mmapID The unique ID of the MMKV instance
247
* @return True if file exists
248
*/
249
public boolean checkExist(String mmapID);
250
```
251
252
**Usage Example:**
253
254
```java
255
public class NameSpaceFileOperationsExample {
256
257
public void demonstrateNameSpaceFileOps(Context context) {
258
// Setup namespaces
259
NameSpace userNameSpace = MMKV.nameSpace(
260
new File(context.getFilesDir(), "users").getAbsolutePath());
261
NameSpace backupNameSpace = MMKV.nameSpace(
262
new File(context.getExternalFilesDir(null), "backup").getAbsolutePath());
263
264
// Create some data in user namespace
265
MMKV userProfile = userNameSpace.mmkvWithID("profile");
266
userProfile.encode("name", "John Doe");
267
userProfile.encode("age", 30);
268
userProfile.encode("email", "john@example.com");
269
270
MMKV userSettings = userNameSpace.mmkvWithID("settings");
271
userSettings.encode("theme", "dark");
272
userSettings.encode("notifications", true);
273
274
// Check file existence and validity within namespace
275
boolean profileExists = userNameSpace.checkExist("profile");
276
boolean profileValid = userNameSpace.isFileValid("profile");
277
boolean settingsExists = userNameSpace.checkExist("settings");
278
boolean settingsValid = userNameSpace.isFileValid("settings");
279
280
Log.d("MMKV", String.format("Profile - exists: %b, valid: %b", profileExists, profileValid));
281
Log.d("MMKV", String.format("Settings - exists: %b, valid: %b", settingsExists, settingsValid));
282
283
// Backup files from user namespace
284
File backupDir = new File(context.getExternalFilesDir(null), "user_backup");
285
backupDir.mkdirs();
286
287
boolean profileBackup = userNameSpace.backupOneToDirectory("profile", backupDir.getAbsolutePath());
288
boolean settingsBackup = userNameSpace.backupOneToDirectory("settings", backupDir.getAbsolutePath());
289
290
Log.d("MMKV", String.format("Backup results - Profile: %b, Settings: %b",
291
profileBackup, settingsBackup));
292
293
// Simulate data loss and restore
294
userNameSpace.removeStorage("profile");
295
userNameSpace.removeStorage("settings");
296
297
Log.d("MMKV", "Simulated data loss - files removed");
298
299
// Restore from backup
300
boolean profileRestore = userNameSpace.restoreOneMMKVFromDirectory("profile", backupDir.getAbsolutePath());
301
boolean settingsRestore = userNameSpace.restoreOneMMKVFromDirectory("settings", backupDir.getAbsolutePath());
302
303
Log.d("MMKV", String.format("Restore results - Profile: %b, Settings: %b",
304
profileRestore, settingsRestore));
305
306
// Verify restored data
307
if (profileRestore) {
308
MMKV restoredProfile = userNameSpace.mmkvWithID("profile");
309
String name = restoredProfile.decodeString("name");
310
int age = restoredProfile.decodeInt("age");
311
Log.d("MMKV", String.format("Restored profile - Name: %s, Age: %d", name, age));
312
}
313
}
314
}
315
```
316
317
### Multi-User Data Organization
318
319
Use namespaces to organize data for multiple users with proper isolation.
320
321
**Usage Example:**
322
323
```java
324
public class MultiUserNameSpaceExample {
325
326
private Map<String, NameSpace> userNameSpaces;
327
private NameSpace sharedNameSpace;
328
329
public void setupMultiUserEnvironment(Context context) {
330
userNameSpaces = new HashMap<>();
331
332
// Create shared namespace for app-wide data
333
File sharedDir = new File(context.getFilesDir(), "shared");
334
sharedNameSpace = MMKV.nameSpace(sharedDir.getAbsolutePath());
335
336
Log.d("MMKV", "Multi-user environment initialized");
337
}
338
339
public NameSpace getUserNameSpace(Context context, String userId) {
340
NameSpace userNameSpace = userNameSpaces.get(userId);
341
if (userNameSpace == null) {
342
// Create user-specific namespace
343
File userDir = new File(context.getFilesDir(), "users/" + userId);
344
userDir.mkdirs();
345
346
userNameSpace = MMKV.nameSpace(userDir.getAbsolutePath());
347
userNameSpaces.put(userId, userNameSpace);
348
349
Log.d("MMKV", "Created namespace for user: " + userId +
350
" at " + userNameSpace.getRootDir());
351
}
352
return userNameSpace;
353
}
354
355
public void storeUserData(Context context, String userId, String username, String email) {
356
NameSpace userNameSpace = getUserNameSpace(context, userId);
357
358
// User-specific data
359
MMKV userProfile = userNameSpace.mmkvWithID("profile");
360
userProfile.encode("user_id", userId);
361
userProfile.encode("username", username);
362
userProfile.encode("email", email);
363
userProfile.encode("created_at", System.currentTimeMillis());
364
365
MMKV userSettings = userNameSpace.mmkvWithID("settings");
366
userSettings.encode("theme", "default");
367
userSettings.encode("language", "en");
368
userSettings.encode("notifications", true);
369
370
MMKV userCache = userNameSpace.mmkvWithID("cache");
371
userCache.encode("last_sync", System.currentTimeMillis());
372
373
// Update shared data (user list)
374
MMKV sharedUserList = sharedNameSpace.mmkvWithID("user_list");
375
Set<String> existingUsers = sharedUserList.decodeStringSet("active_users", new HashSet<>());
376
existingUsers.add(userId);
377
sharedUserList.encode("active_users", existingUsers);
378
379
Log.d("MMKV", String.format("Stored data for user %s (%s)", userId, username));
380
}
381
382
public void switchUser(Context context, String fromUserId, String toUserId) {
383
// Clear current user cache if needed
384
if (fromUserId != null) {
385
NameSpace fromNameSpace = getUserNameSpace(context, fromUserId);
386
MMKV fromCache = fromNameSpace.mmkvWithID("cache");
387
fromCache.clearAllWithKeepingSpace(); // Clear cache but keep file
388
389
Log.d("MMKV", "Cleared cache for user: " + fromUserId);
390
}
391
392
// Load new user data
393
NameSpace toNameSpace = getUserNameSpace(context, toUserId);
394
MMKV toProfile = toNameSpace.mmkvWithID("profile");
395
MMKV toSettings = toNameSpace.mmkvWithID("settings");
396
397
String username = toProfile.decodeString("username", "Unknown");
398
String theme = toSettings.decodeString("theme", "default");
399
boolean notifications = toSettings.decodeBool("notifications", true);
400
401
Log.d("MMKV", String.format("Switched to user %s: theme=%s, notifications=%b",
402
username, theme, notifications));
403
}
404
405
public void deleteUser(Context context, String userId) {
406
NameSpace userNameSpace = userNameSpaces.get(userId);
407
if (userNameSpace != null) {
408
// Remove all user data files
409
userNameSpace.removeStorage("profile");
410
userNameSpace.removeStorage("settings");
411
userNameSpace.removeStorage("cache");
412
413
// Remove from active users list
414
MMKV sharedUserList = sharedNameSpace.mmkvWithID("user_list");
415
Set<String> activeUsers = sharedUserList.decodeStringSet("active_users", new HashSet<>());
416
activeUsers.remove(userId);
417
sharedUserList.encode("active_users", activeUsers);
418
419
// Remove from cache
420
userNameSpaces.remove(userId);
421
422
// Delete user directory
423
File userDir = new File(userNameSpace.getRootDir());
424
deleteDirectory(userDir);
425
426
Log.d("MMKV", "Deleted all data for user: " + userId);
427
}
428
}
429
430
public void backupAllUsers(Context context) {
431
File backupRoot = new File(context.getExternalFilesDir(null), "user_backups");
432
backupRoot.mkdirs();
433
434
// Backup shared data
435
File sharedBackup = new File(backupRoot, "shared");
436
sharedBackup.mkdirs();
437
sharedNameSpace.backupOneToDirectory("user_list", sharedBackup.getAbsolutePath());
438
439
// Backup each user
440
for (Map.Entry<String, NameSpace> entry : userNameSpaces.entrySet()) {
441
String userId = entry.getKey();
442
NameSpace userNameSpace = entry.getValue();
443
444
File userBackup = new File(backupRoot, "user_" + userId);
445
userBackup.mkdirs();
446
447
userNameSpace.backupOneToDirectory("profile", userBackup.getAbsolutePath());
448
userNameSpace.backupOneToDirectory("settings", userBackup.getAbsolutePath());
449
// Don't backup cache as it's temporary
450
451
Log.d("MMKV", "Backed up user: " + userId);
452
}
453
454
Log.d("MMKV", "All user data backed up to: " + backupRoot.getAbsolutePath());
455
}
456
457
private void deleteDirectory(File dir) {
458
if (dir.exists()) {
459
File[] files = dir.listFiles();
460
if (files != null) {
461
for (File file : files) {
462
if (file.isDirectory()) {
463
deleteDirectory(file);
464
} else {
465
file.delete();
466
}
467
}
468
}
469
dir.delete();
470
}
471
}
472
}
473
```
474
475
### Namespace Best Practices
476
477
Guidelines for effective namespace usage and organization.
478
479
**Usage Example:**
480
481
```java
482
public class NameSpaceBestPractices {
483
484
/**
485
* Recommended namespace organization for a typical Android app.
486
*/
487
public static class AppNameSpaceManager {
488
489
private final Context context;
490
private final NameSpace userNameSpace;
491
private final NameSpace cacheNameSpace;
492
private final NameSpace configNameSpace;
493
private final NameSpace logNameSpace;
494
495
public AppNameSpaceManager(Context context) {
496
this.context = context.getApplicationContext();
497
498
// Create well-organized directory structure
499
File baseDir = context.getFilesDir();
500
501
// User data - persistent, important data
502
this.userNameSpace = MMKV.nameSpace(
503
new File(baseDir, "user").getAbsolutePath());
504
505
// Cache data - temporary, can be cleared
506
this.cacheNameSpace = MMKV.nameSpace(
507
context.getCacheDir().getAbsolutePath() + "/mmkv");
508
509
// Configuration - encrypted, critical settings
510
this.configNameSpace = MMKV.nameSpace(
511
new File(baseDir, "config").getAbsolutePath());
512
513
// Logs - for debugging and analytics
514
this.logNameSpace = MMKV.nameSpace(
515
new File(baseDir, "logs").getAbsolutePath());
516
}
517
518
// User data methods
519
public MMKV getUserProfile() {
520
return userNameSpace.mmkvWithID("profile");
521
}
522
523
public MMKV getUserSettings() {
524
return userNameSpace.mmkvWithID("settings");
525
}
526
527
public MMKV getUserHistory() {
528
return userNameSpace.mmkvWithID("history", MMKV.SINGLE_PROCESS_MODE, 2 * 1024 * 1024);
529
}
530
531
// Cache data methods
532
public MMKV getImageCache() {
533
return cacheNameSpace.mmkvWithID("images", MMKV.SINGLE_PROCESS_MODE, 10 * 1024 * 1024);
534
}
535
536
public MMKV getApiCache() {
537
return cacheNameSpace.mmkvWithID("api", MMKV.SINGLE_PROCESS_MODE, 5 * 1024 * 1024);
538
}
539
540
public MMKV getTempStorage() {
541
return cacheNameSpace.mmkvWithID("temp");
542
}
543
544
// Configuration methods (encrypted)
545
public MMKV getAppConfig() {
546
return configNameSpace.mmkvWithID("app", MMKV.SINGLE_PROCESS_MODE, generateConfigKey());
547
}
548
549
public MMKV getServerConfig() {
550
return configNameSpace.mmkvWithID("server", MMKV.MULTI_PROCESS_MODE, generateServerKey());
551
}
552
553
// Logging methods
554
public MMKV getEventLog() {
555
return logNameSpace.mmkvWithID("events", MMKV.SINGLE_PROCESS_MODE, 1024 * 1024);
556
}
557
558
public MMKV getErrorLog() {
559
return logNameSpace.mmkvWithID("errors", MMKV.SINGLE_PROCESS_MODE, 512 * 1024);
560
}
561
562
// Maintenance methods
563
public void clearAllCaches() {
564
cacheNameSpace.mmkvWithID("images").clearAllWithKeepingSpace();
565
cacheNameSpace.mmkvWithID("api").clearAllWithKeepingSpace();
566
cacheNameSpace.mmkvWithID("temp").clearAll();
567
568
Log.d("MMKV", "All caches cleared");
569
}
570
571
public void rotateLogs() {
572
// Archive current logs and create new ones
573
File logBackup = new File(context.getFilesDir(), "log_archive");
574
logBackup.mkdirs();
575
576
logNameSpace.backupOneToDirectory("events", logBackup.getAbsolutePath());
577
logNameSpace.backupOneToDirectory("errors", logBackup.getAbsolutePath());
578
579
// Clear current logs
580
logNameSpace.mmkvWithID("events").clearAll();
581
logNameSpace.mmkvWithID("errors").clearAll();
582
583
Log.d("MMKV", "Logs rotated and archived");
584
}
585
586
public void performMaintenance() {
587
// Trim cache files to reclaim space
588
cacheNameSpace.mmkvWithID("images").trim();
589
cacheNameSpace.mmkvWithID("api").trim();
590
591
// Rotate logs if they're too large
592
MMKV eventLog = logNameSpace.mmkvWithID("events");
593
if (eventLog.totalSize() > 5 * 1024 * 1024) { // 5MB
594
rotateLogs();
595
}
596
597
Log.d("MMKV", "Namespace maintenance completed");
598
}
599
600
private String generateConfigKey() {
601
// Generate app-specific encryption key
602
return "app_config_" + context.getPackageName().hashCode();
603
}
604
605
private String generateServerKey() {
606
// Generate server-specific encryption key
607
return "server_config_" + BuildConfig.APPLICATION_ID.hashCode();
608
}
609
}
610
611
/**
612
* Usage example of the namespace manager.
613
*/
614
public void demonstrateNameSpaceManager(Context context) {
615
AppNameSpaceManager nsManager = new AppNameSpaceManager(context);
616
617
// Store user data
618
MMKV userProfile = nsManager.getUserProfile();
619
userProfile.encode("user_id", 12345);
620
userProfile.encode("name", "John Doe");
621
622
MMKV userSettings = nsManager.getUserSettings();
623
userSettings.encode("theme", "dark");
624
userSettings.encode("notifications", true);
625
626
// Store configuration (encrypted)
627
MMKV appConfig = nsManager.getAppConfig();
628
appConfig.encode("api_endpoint", "https://api.example.com");
629
appConfig.encode("app_secret", "secret-key-12345");
630
631
// Use cache
632
MMKV imageCache = nsManager.getImageCache();
633
imageCache.encode("profile_image", "cached_image_data");
634
635
// Log events
636
MMKV eventLog = nsManager.getEventLog();
637
eventLog.encode("app_started", System.currentTimeMillis());
638
eventLog.encode("user_login", "john_doe");
639
640
// Perform maintenance
641
nsManager.performMaintenance();
642
643
Log.d("MMKV", "Namespace manager demonstration completed");
644
}
645
}
646
```
647
648
## Important Notes
649
650
1. **Directory Management**: Namespaces require directories to exist before creation
651
2. **Data Isolation**: Each namespace maintains completely separate data files
652
3. **Path Consistency**: Always use absolute paths for namespace directories
653
4. **Backup/Restore**: Namespace-aware backup operations only affect files within that namespace
654
5. **Memory Usage**: Each namespace may have its own memory mappings, consider resource usage
655
6. **Organization**: Use meaningful directory names that reflect data purpose (user, cache, config, etc.)
656
7. **Security**: Apply appropriate permissions to namespace directories based on data sensitivity
657
8. **Cleanup**: Remove unused namespaces and their directories when no longer needed