cachedRecord.dart 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import 'package:vitalapp/architecture/storage/text_storage.dart';
  2. import 'package:vitalapp/managers/interfaces/cachedRecord.dart';
  3. class CachedRecordManager implements ICachedRecordManager {
  4. @override
  5. Future<bool?> saveCachedRecord(
  6. String key,
  7. String patientCode,
  8. String type,
  9. String cached,
  10. ) async {
  11. TextStorage cachedRecord = TextStorage(
  12. fileName: key,
  13. directory: "patient/$patientCode/$type",
  14. );
  15. return cachedRecord.save(cached);
  16. }
  17. @override
  18. Future<String?> readCachedRecord(
  19. String key,
  20. String patientCode,
  21. String type,
  22. ) async {
  23. TextStorage cachedRecord = TextStorage(
  24. fileName: key,
  25. directory: "patient/$patientCode/$type",
  26. );
  27. String? value = await cachedRecord.read();
  28. return value;
  29. }
  30. @override
  31. Future<bool?> deleteCachedRecord(
  32. String key,
  33. String patientCode,
  34. String type,
  35. ) async {
  36. TextStorage cachedRecord = TextStorage(
  37. fileName: key,
  38. directory: "patient/$patientCode/$type",
  39. );
  40. return cachedRecord.delete();
  41. }
  42. @override
  43. Future<bool?> deleteDirectory(
  44. String patientCode,
  45. String type,
  46. ) async {
  47. TextStorage cachedRecord = TextStorage(
  48. fileName: '',
  49. directory: "patient/$patientCode/$type",
  50. );
  51. return cachedRecord.deleteDirectory();
  52. }
  53. }