UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '51OcDhy7MlDiWtbdWgCkH3mBNlNZGg8vRMGQaF0oZ+A='
WHERE
key_id = 'b7b09ff0d834c5a35b5dc4710f15456686ead9b505bf0470a331250c98fb29b4'
AND (
token = '51OcDhy7MlDiWtbdWgCkH3mBNlNZGg8vRMGQaF0oZ+A='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)