UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'b58ykKb0HmGUURjB3HlPgGOJpI6ppngEP2aAsc3zx6M='
WHERE
key_id = 'ff91765fc40a35b477270dc3d19c73a0de4ad0af9db6fdca933ec50f3164ee10'
AND (
token = 'b58ykKb0HmGUURjB3HlPgGOJpI6ppngEP2aAsc3zx6M='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)