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