UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'D9qmEq0ls3f2HyYm0P3TReBYhPr8FmJzJV3tP28ZG0E='
WHERE
key_id = '3798b2f18a35d7709bee31407db2db9b8eb340d2467f9e4f2b72e6fc344b1047'
AND (
token = 'D9qmEq0ls3f2HyYm0P3TReBYhPr8FmJzJV3tP28ZG0E='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)