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