UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'tMoTjkDhnEQ9qoyrbU1veJKPT8cS346S8r/1FOGA5qc='
WHERE
key_id = 'ba3ed98b86927fd51fc80dd92246790819a0b9b166d9336da9e9b83712ddfec0'
AND (
token = 'tMoTjkDhnEQ9qoyrbU1veJKPT8cS346S8r/1FOGA5qc='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)