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