UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '0G1dY2xRXfOEyFtOQ4zsanE4sC4olmPcC2qFobmm0jk='
WHERE
key_id = 'ae7003434f8aaa64453105c322e15e2333246346f432086ed1444d76919798b2'
AND (
token = '0G1dY2xRXfOEyFtOQ4zsanE4sC4olmPcC2qFobmm0jk='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)