UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'ENYC89hCS3EuluNsz7mdmTpVfCQgPM8+sPYy6sUV7+k='
WHERE
key_id = 'a97bada0957f7598b6e94d5f5a82861038815c05b544e11e9792ec95a27bdab5'
AND (
token = 'ENYC89hCS3EuluNsz7mdmTpVfCQgPM8+sPYy6sUV7+k='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)