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