Closed schmunk42 closed 7 years ago
Sorry for the late reply. Generally it's not a good idea to have a get method do any kind of writes. It introduces a lot of confusion. Perhaps a new method named getOrSet
?
You're absolutely right with get and write!
getOrSet
looks okay to me, but not 100% perfect.
What's about a "softSet", which only creates an entry when there's none, don't know a good name though.
Maybe we could just start with a has
method? :)
Hmmm, upsert
does not look right to me, at least for my use-case.
But how would it differ from set
?
Hmm, now that I've re-read your initial post, your request is a rather specific one. Pls disregard my suggestion.
+1+
How about adding a forth parameter to
get()
which would create a deactivated entry, if there is no setting in the database yet?Static helper as an example:
Any thoughts?
PS: I think the check should be improved a bit...