North-Seattle-College / ad440-winter2021-thursday-repo

NSC AD 440 Winter 2021 Thursday cohort practicum repo
Apache License 2.0
2 stars 27 forks source link

[Task] Expand user/{user_id} redis cache to invalidate duplicate/invalid cache #191

Closed chonger878 closed 3 years ago

chonger878 commented 3 years ago

Is your feature request related to a problem? Please describe. This task requires code to assist with invalidating the cache (replace/deleting). In addition, we need to make sure that there is no duplicate user_id and that you cannot delete user_id that is not there.

Describe the solution you'd like I wrote a "validator" method for the invalidation process. This method would check to see if the redis is cachable or is clearable before replacing it or deleting it.

Describe alternatives you've considered N/A

Additional context This is an extension of issue #138. In addition, this was a (unintentional) collaboration of two individuals. I also updated the REDIS_HOST and REDIS_PORT to be environmental variables.

TESTING DOCUMENTATION (copied and pasted from PR #231)

Before you test, please make sure under 'REDIS_HOST' and 'REDIS_PORT', please specify which ports and hosts you would like to use

1.)If you have VSC code open and navigated to your function, go ahead and run/debug 2.) Open Postman 3.) Run GET 4.) Your expected output on VSC should be the logs and that the results were all cached 5.)Run PUT 6.) Your expected output on VSC should be the same as above, except you will get a message that the cache was updated/unable to update, and a user_id should automatically generate in that SQL table. a.) Enter whatever you like for first name, last name, email address b.) You could also make an incomplete entry (like missing first name, email) to see if you get an error message. 7.) Run DELETE 8.)You should get a message that your cache has been cleared or deletion was failed.

Special thanks to PR #223 to help me with working on these documentation.

chonger878 commented 3 years ago

Date Task Time 3/1 Research on invalidating cache 1 hr 3/2 Modified PUT method in the User_ID API Trigger code 1 hr 3/3 Modified DELETE method in User_ID API Trigger code 1 hr 3/4 Continued work on coding 2 hrs 3/5 Reviewed/ Cleaned up code and worked on documentation for steps 3 hrs 8 total hours