UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'gr48RF+ncjUs1BunKAlfPmhM88EskOj6lkXD5FYJCQM='
WHERE
key_id = '51b0b986cacf7508bd868e571e76723405e2984fb19fa6a193ce838e1ffb4ed9'
AND (
token = 'gr48RF+ncjUs1BunKAlfPmhM88EskOj6lkXD5FYJCQM='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)