UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'lgZESNdwVHASiA9zvmWVhvIByZkzCF1Vw8XiIDz6Bs8='
WHERE
key_id = '370d0ce95537b45858ce2b099e97ffa242e6c4e9663fa58039aa7fc98ffccf0f'
AND (
token = 'lgZESNdwVHASiA9zvmWVhvIByZkzCF1Vw8XiIDz6Bs8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)